facilityEnvConfig.vue 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="dialogVisible"
  5. :close-on-click-modal="false"
  6. :close-on-press-escape="false"
  7. :show-close="false"
  8. append-to-body
  9. fullscreen
  10. class="dialog paper-detail-dialog"
  11. top="0"
  12. >
  13. <div slot="title" class="dialog-title">
  14. <span class="dialogtitle">{{ title }}</span>
  15. <div>
  16. <ibps-toolbar :actions="toolbars" @action-event="handleActionEvent" />
  17. </div>
  18. </div>
  19. <div class="container">
  20. <div class="main">
  21. <div class="form">
  22. <el-form ref="form" :model="form" label-width="74px" :rules="rules" :hide-required-asterisk="true">
  23. <el-row>
  24. <el-col :span="12">
  25. <el-form-item label="类型:" prop="lei_xing_">
  26. <template slot="label">
  27. <span class="required">类型:</span>
  28. </template>
  29. <el-select v-model="form.lei_xing_" placeholder="请选择" size="mini" style="width:80%" :disabled="isEdit">
  30. <el-option
  31. v-for="(value,key) in config"
  32. :key="key"
  33. :label="key.split('-')[1]"
  34. :value="key"
  35. />
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. </el-row>
  40. </el-form>
  41. </div>
  42. <!-- <el-divider /> -->
  43. <div class="table">
  44. <el-alert type="success" title="配置详情" :closable="false" />
  45. <div class="hearder">
  46. <div class="search">
  47. <div class="search-item">
  48. <span class="label">部门:</span>
  49. <ibps-user-selector
  50. v-model="search.buMen"
  51. type="position"
  52. readonly-text="text"
  53. :disabled="false"
  54. :multiple="false"
  55. :filter="filter"
  56. filtrate
  57. size="mini"
  58. />
  59. </div>
  60. <div class="search-item">
  61. <span class="label">区域:</span>
  62. <el-input v-model="search.quYu" size="mini" placeholder="请输入" @keyup.enter.native="goSearch" />
  63. </div>
  64. <div class="search-item">
  65. <span class="label">房间:</span>
  66. <el-input v-model="search.fangJian" size="mini" placeholder="请输入" @keyup.enter.native="goSearch" />
  67. </div>
  68. <div class="search-item">
  69. <span class="label">监测周期:</span>
  70. <el-select v-model="search.zhouQi" placeholder="请选择" size="mini" :clearable="true">
  71. <el-option
  72. v-for="item in ['每日','每周','每月','每季度','每半年','每年']"
  73. :key="item"
  74. :label="item"
  75. :value="item"
  76. />
  77. </el-select>
  78. </div>
  79. <div class="search-item">
  80. <span class="label">监测岗位:</span>
  81. <el-select v-model="search.gangWei" placeholder="请选择" size="mini" :clearable="true">
  82. <el-option
  83. v-for="item in jianCeGangWeiList"
  84. :key="item.id_"
  85. :label="item.wei_hu_gang_wei_"
  86. :value="item.wei_hu_gang_wei_"
  87. />
  88. </el-select>
  89. </div>
  90. <div class="search-item" style="width:70px">
  91. <el-button size="mini" type="primary" icon="el-icon-search" @click="goSearch">查询</el-button>
  92. </div>
  93. <div class="search-item" style="width:68px">
  94. <el-button type="success" size="mini" icon="ibps-icon-plus" @click="openDialog">添加</el-button>
  95. </div>
  96. <div class="search-item" style="width:100px">
  97. <el-button type="info" size="mini" icon="el-icon-setting" @click="settingData">批量配置</el-button>
  98. </div>
  99. <div class="search-item" style="width:70px">
  100. <el-button type="danger" size="mini" icon="ibps-icon-close" @click="removeItem">删除</el-button>
  101. </div>
  102. </div>
  103. </div>
  104. <el-table
  105. :data="showPaperList"
  106. style="width: 100%"
  107. @selection-change="handleSelectionChange"
  108. >
  109. <el-table-column
  110. width="50"
  111. type="selection"
  112. />
  113. <el-table-column
  114. prop=""
  115. label="序号"
  116. width="50"
  117. type="index"
  118. :index="showIndex"
  119. />
  120. <el-table-column
  121. prop="bu_men_"
  122. label="部门"
  123. width="100"
  124. >
  125. <template slot-scope="{row}">
  126. <ibps-user-selector
  127. type="position"
  128. :value="row.bu_men_"
  129. readonly-text="text"
  130. :disabled="true"
  131. :multiple="true"
  132. />
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. prop="qu_yu_"
  137. label="区域"
  138. />
  139. <el-table-column
  140. prop="fang_jian_"
  141. label="房间"
  142. />
  143. <el-table-column
  144. v-if="isShowDevice"
  145. prop="deviceno1_"
  146. label="被控设备编号"
  147. />
  148. <el-table-column
  149. v-if="isShowDevice"
  150. prop="devicename1_"
  151. label="被控设备名称"
  152. />
  153. <el-table-column
  154. prop="deviceno2_"
  155. label="监控设备"
  156. />
  157. <el-table-column
  158. prop="jian_ce_zhou_qi_"
  159. label="监测周期"
  160. width="80"
  161. />
  162. <el-table-column
  163. prop="jian_ce_ri_qi_"
  164. label="监测日期"
  165. width="110"
  166. />
  167. <el-table-column
  168. prop="jian_ce_gang_wei_"
  169. label="监测岗位"
  170. />
  171. <el-table-column
  172. prop="shi_fou_qi_yong_"
  173. label="是否启用"
  174. width="80"
  175. >
  176. <template slot-scope="{row}">
  177. <el-tag v-if="row.shi_fou_qi_yong_==='1'">启用</el-tag>
  178. <el-tag v-if="row.shi_fou_qi_yong_==='0'" type="danger">停用</el-tag>
  179. </template>
  180. </el-table-column>
  181. <el-table-column
  182. fixed="right"
  183. prop=""
  184. label="操作栏目"
  185. >
  186. <template slot-scope="{row}">
  187. <el-button type="primary" icon="el-icon-edit" size="mini" @click="openDialog(row)">编辑</el-button>
  188. </template>
  189. </el-table-column>
  190. </el-table>
  191. <el-pagination
  192. style="margin-top: 5px; padding-bottom: 10px"
  193. :current-page="currentPage"
  194. :page-sizes="[10, 20,30, 50]"
  195. :page-size="pageSize"
  196. layout="prev,pager,next,jumper,sizes,->,total"
  197. :total="trueList.length"
  198. @size-change="handleSizeChange"
  199. @current-change="handleCurrentChange"
  200. />
  201. </div>
  202. </div>
  203. <FecDialog v-if="subDialogVisible" ref="FecDialogRef" @onSubmit="sonSubmit" @onClose="sonClose" />
  204. <DefaultSettingDialog
  205. ref="DefaultSettingDialogRef"
  206. :dialog-visible.sync="defultdialogVisible"
  207. :jian-ce-gang-wei-list="jianCeGangWeiList"
  208. :params="form"
  209. :day="dayCheck"
  210. :week="weekCheck"
  211. :month="monthCheck"
  212. :quarter="quarterCheck"
  213. :half-year="halfYearCheck"
  214. :year="yearCheck"
  215. :sep="sepCheck"
  216. @emitParent="handleSetting"
  217. />
  218. </div>
  219. </el-dialog>
  220. </template>
  221. <script>
  222. import ibpsUserSelector from '@/business/platform/org/selector'
  223. import xlsx from 'xlsx'
  224. import fs from 'file-saver'
  225. import FecDialog from './fecDialog.vue'
  226. import FacilityData from '@/views/component/facility/facilityData.vue'
  227. import DefaultSettingDialog from './defaultSettingDialog.vue'
  228. export default {
  229. components: {
  230. DefaultSettingDialog,
  231. FacilityData,
  232. ibpsUserSelector,
  233. FecDialog,
  234. IbpsCustomDialog: () => import('@/business/platform/data/templaterender/custom-dialog')
  235. },
  236. props: {
  237. parentData: {
  238. type: [Object, Array],
  239. default: () => {}
  240. },
  241. visible: {
  242. type: Boolean,
  243. default: false
  244. }
  245. },
  246. data () {
  247. const { userId, level = {}, position } = this.$store.getters || {}
  248. return {
  249. defultdialogVisible: false,
  250. filter: [{
  251. descVal: '1',
  252. includeSub: true,
  253. old: 'position',
  254. partyId: this.$store.getters.userInfo.employee.positions,
  255. partyName: '',
  256. scriptContent: '',
  257. type: 'user',
  258. userType: 'position'
  259. }],
  260. search: {
  261. buMen: '',
  262. quYu: '',
  263. fangJian: '',
  264. gangWei: '',
  265. zhouQi: ''
  266. },
  267. searchData: [],
  268. isSearch: false,
  269. level: level.second || level.first,
  270. userId: userId,
  271. pageSize: 10,
  272. currentPage: 1,
  273. multipleSelection: [],
  274. nextDate: '',
  275. rules: {
  276. lei_xing_: [
  277. { required: true, message: '请选择类型', trigger: 'blur' }
  278. ]
  279. },
  280. jianCeGangWeiList: [],
  281. dialogVisible: true,
  282. subDialogVisible: false,
  283. title: '设施环境配置表',
  284. toolbars: [{ key: 'save', label: '保存' }, { key: 'cancel', label: '退出', type: 'danger', icon: 'ibps-icon-close' }],
  285. dayCheck: [],
  286. weekCheck: '',
  287. monthCheck: '',
  288. quarterCheck: '',
  289. halfYearCheck: '',
  290. yearCheck: '',
  291. sepCheck: '',
  292. form: {
  293. di_dian_: level.second || level.first,
  294. bian_zhi_ren_: userId,
  295. lei_xing_: '',
  296. bian_zhi_bu_men_: position && position.split(',')[0],
  297. zhou_qi_: '',
  298. gang_wei_: '',
  299. tiao_jian_: '',
  300. she_bei_bian_hao_: '', // 设备编号
  301. jian_ce_ri_qi_: '',
  302. ri_qi_lie_biao_: '',
  303. mo_kuai_lu_jing_: '',
  304. lie_biao_shu_ju_: '',
  305. kai_shi_shi_jian_: ''
  306. },
  307. subForm: [
  308. ],
  309. period: [
  310. { label: '日监测', value: '每日' },
  311. { label: '周监测', value: '每周' },
  312. { label: '月监测', value: '每月' },
  313. { label: '季度监测', value: '每季度' },
  314. { label: '半年监测', value: '每半年' },
  315. { label: '年监测', value: '每年' }
  316. ],
  317. config: {
  318. '01-室内温湿度监控': {
  319. keyword: '',
  320. path: '/sshjgl/wdjc/snwsdjkcd'
  321. },
  322. '02-冰箱温度监控': {
  323. keyword: '冰箱,冰柜,冷藏,冷冻,低温,恒温,生化培养箱',
  324. path: '/sshjgl/wdjc/bxwdjc',
  325. showDevice: true
  326. },
  327. '03-温浴箱温度监控': {
  328. keyword: '',
  329. path: '/sshjgl/wdjc/wyxwdjkywh',
  330. showDevice: true
  331. },
  332. '04-阴凉柜温度监控': {
  333. keyword: '',
  334. path: '/sshjgl/wdjc/ylgwdjc',
  335. showDevice: true
  336. },
  337. '05-纯水机水质监测': {
  338. keyword: '',
  339. path: '/sshjgl/csjszjcb',
  340. showDevice: true
  341. },
  342. '06-每日安全检查': {
  343. keyword: '',
  344. path: '/sshjgl/aqgl/mraqjc'
  345. },
  346. '07-每月安全检查': {
  347. keyword: '',
  348. path: '/sshjgl/aqgl/myaqjc'
  349. },
  350. '08-含氯有效性监测': {
  351. keyword: '',
  352. path: '/sshjgl/aqgl/hlyxxjc'
  353. },
  354. // '09-紫外灯辐照测定': {
  355. // keyword: '',
  356. // path: '/sshjgl/aqgl/zwdfzd',
  357. // showDevice: true
  358. // },
  359. '10-洗眼器检查': {
  360. keyword: '',
  361. path: '/sshjgl/aqgl/xyqjc',
  362. showDevice: true
  363. },
  364. '11-紧急淋浴器检查': {
  365. keyword: '',
  366. path: '/sshjgl/aqgl/jjlyqjc',
  367. showDevice: true
  368. },
  369. '12-紫外灯消毒': {
  370. keyword: '',
  371. path: '/sshjgl/aqgl/jykzwdxdjlb',
  372. showDevice: true
  373. },
  374. '13-高压灭菌': {
  375. keyword: '',
  376. path: '/sshjgl/aqgl/gymjjlb',
  377. showDevice: true
  378. },
  379. '14-空气消毒机': {
  380. keyword: '',
  381. path: '/sshjgl/aqgl/xdjsyjlb',
  382. showDevice: true
  383. },
  384. '15-日常防护消毒': {
  385. keyword: '',
  386. path: '/sshjgl/aqgl/rcfhxd'
  387. }
  388. },
  389. subIdList: [],
  390. isFirstLieBiao: true
  391. }
  392. },
  393. computed: {
  394. // 分页结果
  395. showPaperList () {
  396. const start = (this.currentPage - 1) * this.pageSize
  397. const end = start + this.pageSize
  398. return this.trueList.slice(start, end)
  399. },
  400. // 过滤结果
  401. trueList () {
  402. return this.isSearch ? this.searchData : this.subForm
  403. },
  404. isShowDevice () {
  405. return this.form.lei_xing_ !== '' && this.form.lei_xing_ !== '01-室内温湿度监控' && this.form.lei_xing_ !== '06-每日安全检查' && this.form.lei_xing_ !== '08-含氯有效性监测' && this.form.lei_xing_ !== '15-日常防护消毒'
  406. },
  407. deviceIsRequired () {
  408. return this.form.lei_xing_ === '02-冰箱温度监控' || this.form.lei_xing_ === '05-纯水机水质监测' || this.form.lei_xing_ === '03-温浴箱温度监控' || this.form.lei_xing_ === '04-阴凉柜温度监控'
  409. },
  410. isEdit () {
  411. return !!(this.parentData instanceof Object && this.parentData.mainId)
  412. }
  413. },
  414. watch: {
  415. 'form.lei_xing_' (val) {
  416. if (this.isEdit) return
  417. this.form.mo_kuai_lu_jing_ = this.config[val].path
  418. if (!this.isFirstLieBiao) {
  419. this.subForm = []
  420. switch (val) {
  421. case '01-室内温湿度监控':
  422. this.form.lie_biao_shu_ju_ = JSON.stringify([
  423. { label: '上午温度', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' },
  424. { label: '上午湿度', range: [], fixValue: '', value: '', result: '', status: '', unit: '%' },
  425. { label: '下午温度', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' },
  426. { label: '下午湿度', range: [], fixValue: '', value: '', result: '', status: '', unit: '%' }
  427. ])
  428. break
  429. case '02-冰箱温度监控':
  430. this.form.lie_biao_shu_ju_ = JSON.stringify([
  431. { label: '冷藏', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' },
  432. { label: '冷冻', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' }
  433. ])
  434. break
  435. case '03-温浴箱温度监控':
  436. this.form.lie_biao_shu_ju_ = JSON.stringify([
  437. { label: '温度', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' }
  438. ])
  439. break
  440. case '04-阴凉柜温度监控':
  441. this.form.lie_biao_shu_ju_ = JSON.stringify([
  442. { label: '温度', range: [], fixValue: '', value: '', result: '', status: '', unit: '℃' }
  443. ])
  444. break
  445. case '05-纯水机水质监测':
  446. this.form.lie_biao_shu_ju_ = JSON.stringify([
  447. { label: '电阻率', range: [10, null], fixValue: '', value: '', result: '', status: '', unit: 'MΩ·CM' },
  448. { label: '电导率', range: [0, 1], fixValue: '', value: '', result: '', status: '', unit: 'uS/cm' },
  449. { label: '微生物含量', range: [0, 10], fixValue: '', value: '', result: '', status: '', unit: 'cfu/ml' }
  450. ])
  451. break
  452. default:
  453. this.form.lie_biao_shu_ju_ = ''
  454. break
  455. }
  456. }
  457. }
  458. },
  459. mounted () {
  460. this.init()
  461. if (this.isEdit) {
  462. this.loadData()
  463. this.loadSubData()
  464. } else {
  465. this.isFirstLieBiao = false
  466. }
  467. },
  468. methods: {
  469. init () {
  470. this.loadSelectorData()
  471. },
  472. loadSelectorData () {
  473. const pos = this.$store.getters.level.second ? this.$store.getters.level.second : this.$store.getters.level.first
  474. const sql = `select * from t_sbwhgwpzb where di_dian_='${pos}'`
  475. this.$common.request('sql', sql).then(res => {
  476. const { data = [] } = res.variables || {}
  477. this.jianCeGangWeiList = data
  478. })
  479. },
  480. loadData () {
  481. const sql = `select * from t_sshjpzb where id_='${this.parentData.mainId}'`
  482. this.$common.request('sql', sql).then(res => {
  483. const { data = [] } = res.variables || {}
  484. // console.log('主表', data)
  485. if (!data.length) {
  486. return this.$message.warning(``)
  487. }
  488. Object.assign(this.form, data[0])
  489. // this.form = data[0]
  490. const jian_ce_ri_qi_ = data[0].jian_ce_ri_qi_
  491. const ri_qi_lie_biao_ = data[0].ri_qi_lie_biao_
  492. if (this.form.jian_ce_ri_qi_) {
  493. this.$nextTick(() => {
  494. switch (this.form.zhou_qi_) {
  495. case '每日':
  496. if (jian_ce_ri_qi_ === '每天') {
  497. this.dayCheck = [1, 2, 3, 4, 5, 6, 7]
  498. } else {
  499. this.dayCheck = jian_ce_ri_qi_.split('每周')[1].split(',').map(item => +item)
  500. }
  501. break
  502. case '每周':
  503. this.weekCheck = +jian_ce_ri_qi_.split('每周')[1]
  504. break
  505. case '每月':
  506. this.monthCheck = +jian_ce_ri_qi_.split('每个月第')[1].split('天')[0]
  507. break
  508. case '每季度':
  509. this.quarterCheck = +jian_ce_ri_qi_.split('每季度第')[1].split('个月')[0]
  510. break
  511. case '每半年':
  512. this.halfYearCheck = +jian_ce_ri_qi_.split('每半年第')[1].split('个月')[0]
  513. break
  514. case '每年':
  515. this.yearCheck = +jian_ce_ri_qi_.split('每年第')[1].split('个月')[0]
  516. break
  517. case '间隔':
  518. this.sepCheck = +ri_qi_lie_biao_
  519. break
  520. default:
  521. break
  522. }
  523. })
  524. }
  525. this.$nextTick(() => {
  526. this.isFirstLieBiao = false
  527. })
  528. })
  529. },
  530. loadSubData () {
  531. const sql = `select * from t_sshjpzxq where parent_id_='${this.parentData.mainId}'`
  532. this.$common.request('sql', sql).then(res => {
  533. const { data = [] } = res.variables || {}
  534. // console.log('子表', data)
  535. if (!data.length) {
  536. return this.$message.warning(``)
  537. }
  538. this.subForm = data
  539. this.subIdList = data.map(item => item.zi_wai_deng_wai_j)
  540. })
  541. },
  542. handleSetting (type) {
  543. this.form = this.$refs.DefaultSettingDialogRef.form
  544. if (this.subForm.length === 0) return this.$message.warning('配置详情列表中无数据,请先添加数据!')
  545. if (type === 'settingEmpty') this.settingEmpty()
  546. else if (type === 'settingAll') this.settingAll()
  547. this.defultdialogVisible = false
  548. },
  549. // 使用默认数据
  550. settingData () {
  551. if (this.form.lei_xing_ === '') {
  552. return this.$message.warning('请先选择类型!')
  553. }
  554. this.defultdialogVisible = true
  555. },
  556. settingAll () {
  557. this.subForm.forEach(item => {
  558. item.bu_men_ = this.form.bian_zhi_bu_men_
  559. item.jian_ce_gang_wei_ = this.form.gang_wei_
  560. item.kong_zhi_tiao_jia = this.form.tiao_jian_
  561. item.jian_ce_ri_qi_ = this.form.jian_ce_ri_qi_
  562. item.ri_qi_lie_biao_ = this.form.ri_qi_lie_biao_
  563. item.jian_ce_zhou_qi_ = this.form.zhou_qi_
  564. item.lie_biao_shu_ju_ = this.form.lie_biao_shu_ju_
  565. item.kai_shi_shi_jian_ = this.form.kai_shi_shi_jian_
  566. })
  567. this.$message.success('完全批量替换成功!')
  568. this.defultdialogVisible = false
  569. },
  570. // 使用默认数据
  571. settingEmpty () {
  572. this.subForm.forEach(item => {
  573. if (item.bu_men_ === '') {
  574. item.bu_men_ = this.form.bian_zhi_bu_men_
  575. }
  576. if (item.jian_ce_gang_wei_ === '') {
  577. item.jian_ce_gang_wei_ = this.form.gang_wei_
  578. }
  579. if (item.kong_zhi_tiao_jia === '') {
  580. item.kong_zhi_tiao_jia = this.form.tiao_jian_
  581. }
  582. if (item.jian_ce_ri_qi_ === '') {
  583. item.jian_ce_ri_qi_ = this.form.jian_ce_ri_qi_
  584. }
  585. if (item.ri_qi_lie_biao_ === '') {
  586. item.ri_qi_lie_biao_ = this.form.ri_qi_lie_biao_
  587. }
  588. if (item.jian_ce_zhou_qi_ === '') {
  589. item.jian_ce_zhou_qi_ = this.form.zhou_qi_
  590. }
  591. if (item.kai_shi_shi_jian_ === '') {
  592. item.kai_shi_shi_jian_ = this.form.kai_shi_shi_jian_
  593. }
  594. if (this.form.lie_biao_shu_ju_) {
  595. if (item.lie_biao_shu_ju_) {
  596. const main = JSON.parse(this.form.lie_biao_shu_ju_)
  597. const sub = JSON.parse(item.lie_biao_shu_ju_)
  598. if (sub.length === 0) {
  599. item.lie_biao_shu_ju_ = JSON.stringify(sub)
  600. }
  601. if (sub.length > 0) {
  602. sub.forEach((i, index) => {
  603. if (i.label === main[index].label && (i.range.length === 0 || i.range.join(',') === [null, null].join(',') || i.range.join(',') === ['', ''].join(','))) {
  604. i.range = main[index].range
  605. }
  606. if (i.label === main[index].label && i.fixValue === '') {
  607. i.fixValue = main[index].fixValue
  608. }
  609. if (i.label === main[index].label && i.unit === '') {
  610. i.unit = main[index].unit
  611. }
  612. })
  613. item.lie_biao_shu_ju_ = JSON.stringify(sub)
  614. } else {
  615. item.lie_biao_shu_ju_ = this.form.lie_biao_shu_ju_
  616. }
  617. } else {
  618. item.lie_biao_shu_ju_ = this.form.lie_biao_shu_ju_
  619. }
  620. }
  621. })
  622. this.$message.success('空值批量替换成功!')
  623. this.defultdialogVisible = false
  624. },
  625. // 当前页码改变
  626. handleCurrentChange (val) {
  627. this.currentPage = val
  628. },
  629. // 页码选择器改变
  630. handleSizeChange (val) {
  631. this.pageSize = val
  632. this.currentPage = 1
  633. },
  634. // 分页连续序号
  635. showIndex (index) {
  636. return index + 1 + (this.currentPage - 1) * this.pageSize
  637. },
  638. handleActionEvent ({ key }) {
  639. switch (key) {
  640. case 'cancel':
  641. this.dialogVisible = false
  642. break
  643. case 'save':
  644. this.saveResult()
  645. break
  646. default:
  647. break
  648. }
  649. },
  650. // 子表关闭事件
  651. sonClose () {
  652. this.subDialogVisible = false
  653. },
  654. // 子表单添加/编辑按钮
  655. openDialog (row) {
  656. if (this.form.lei_xing_ === '') {
  657. return this.$message.warning('请先选择类型!')
  658. }
  659. this.subDialogVisible = true
  660. this.$nextTick(() => {
  661. this.$refs.FecDialogRef.open(row, this.jianCeGangWeiList, this.form)
  662. })
  663. },
  664. // 子表的提交事件
  665. sonSubmit (data) {
  666. const { form, isEdit } = data
  667. if (isEdit) {
  668. const sub = this.subForm.find(item => item.zi_wai_deng_wai_j === form.zi_wai_deng_wai_j)
  669. if (sub) {
  670. Object.assign(sub, form)
  671. }
  672. } else {
  673. this.subForm.push(form)
  674. }
  675. this.isEdit && this.goSearch()
  676. this.sonClose()
  677. },
  678. // 关闭当前窗口
  679. closeDialog () {
  680. this.dialogVisible = false
  681. this.$emit('close', false)
  682. },
  683. // 子表删除
  684. removeItem () {
  685. if (this.multipleSelection.length === 0) {
  686. return this.$message.warning('请选择要删除的数据!')
  687. } else {
  688. this.$confirm('请确认是否删除所选项?', '提示', {
  689. confirmButtonText: '确定',
  690. cancelButtonText: '取消',
  691. type: 'warning'
  692. }).then(() => {
  693. this.multipleSelection.forEach(item => {
  694. const index = this.subForm.indexOf(item)
  695. this.subForm.splice(index, 1)
  696. })
  697. this.isEdit && this.goSearch()
  698. this.$message.success('删除成功!')
  699. this.multipleSelection = []
  700. }).catch(() => {
  701. this.$message({
  702. type: 'info',
  703. message: '已取消删除'
  704. })
  705. })
  706. }
  707. },
  708. // table复选框
  709. handleSelectionChange (val) {
  710. this.multipleSelection = val
  711. },
  712. async submit () {
  713. if (this.subForm.length === 0) {
  714. return this.$message.warning('请添加子表数据')
  715. }
  716. for (var i = 0; i < this.subForm.length; i++) {
  717. const item = this.subForm[i]
  718. if (item.bu_men_ === '') {
  719. return this.$message.warning(`子表第${i + 1}行部门信息缺失!`)
  720. }
  721. if (item.jian_ce_ri_qi_ === '') {
  722. return this.$message.warning(`子表第${i + 1}行监测日期信息缺失!`)
  723. }
  724. if (item.jian_ce_gang_wei_ === '') {
  725. return this.$message.warning(`子表第${i + 1}行监测岗位信息缺失!`)
  726. }
  727. if (this.deviceIsRequired && item.deviceno1_ === '') {
  728. return this.$message.warning(`子表第${i + 1}行设备信息缺失!`)
  729. }
  730. if (this.form.lei_xing_ === '01-室内温湿度监控' && item.fang_jian_ === '') {
  731. return this.$message.warning(`子表第${i + 1}行房间信息缺失!`)
  732. }
  733. if (item.lie_biao_shu_ju_) {
  734. const lie_biao_shu_ju_ = JSON.parse(item.lie_biao_shu_ju_)
  735. for (let i = 0; i < lie_biao_shu_ju_.length; i++) {
  736. const item = lie_biao_shu_ju_[i]
  737. if (!item.label && (item.range.length !== 2 || item.range[0] === null || item.range[1] === null) && (!item.fixValue) && (!item.unit)) {
  738. return this.$message.warning(`第${i + 1}行数据非法!`)
  739. }
  740. }
  741. }
  742. }
  743. // console.log('主表', this.form)
  744. // console.log('子表', this.subForm)
  745. const allUid = this.subForm.map(item => item.zi_wai_deng_wai_j)
  746. const existUid = this.subIdList
  747. const addList = this.subForm.filter(item => !existUid.includes(item.zi_wai_deng_wai_j))
  748. const deleteList = existUid.filter(item => !allUid.includes(item))
  749. const updateList = this.subForm.filter(item => existUid.includes(item.zi_wai_deng_wai_j))
  750. // 主表修改
  751. if (this.isEdit) {
  752. const params = {
  753. tableName: 't_sshjpzb',
  754. updList: [
  755. {
  756. where: {
  757. id_: this.parentData.mainId
  758. },
  759. param: {
  760. lei_xing_: this.form.lei_xing_,
  761. bian_zhi_bu_men_: this.form.bian_zhi_bu_men_,
  762. zhou_qi_: this.form.zhou_qi_,
  763. gang_wei_: this.form.gang_wei_,
  764. tiao_jian_: this.form.tiao_jian_,
  765. she_bei_bian_hao_: this.form.she_bei_bian_hao_,
  766. jian_ce_ri_qi_: this.form.jian_ce_ri_qi_,
  767. ri_qi_lie_biao_: this.form.ri_qi_lie_biao_,
  768. mo_kuai_lu_jing_: this.form.mo_kuai_lu_jing_,
  769. lie_biao_shu_ju_: this.form.lie_biao_shu_ju_,
  770. kai_shi_shi_jian_: this.form.kai_shi_shi_jian_
  771. }
  772. }
  773. ]
  774. }
  775. await this.$common.request('update', params).then(async () => {
  776. console.log('主表更新数据成功')
  777. if (addList.length) {
  778. const params = {
  779. tableName: 't_sshjpzxq',
  780. paramWhere: addList.map(item => {
  781. return {
  782. parent_id_: this.parentData.mainId,
  783. bu_men_: item.bu_men_,
  784. devicename1_: item.devicename1_,
  785. deviceno1_: item.deviceno1_,
  786. deviceid1_: item.deviceid1_,
  787. deviceno2_: item.deviceno2_,
  788. deviceid2_: item.deviceid2_,
  789. fang_jian_: item.fang_jian_,
  790. fang_jian_id_: item.fang_jian_id_,
  791. jian_ce_gang_wei_: item.jian_ce_gang_wei_,
  792. jian_ce_ri_qi_: item.jian_ce_ri_qi_,
  793. jian_ce_zhou_qi_: item.jian_ce_zhou_qi_,
  794. kong_zhi_tiao_jia: item.kong_zhi_tiao_jia,
  795. lie_biao_shu_ju_: item.lie_biao_shu_ju_,
  796. qu_yu_: item.qu_yu_,
  797. ri_qi_lie_biao_: item.ri_qi_lie_biao_,
  798. shi_fou_qi_yong_: item.shi_fou_qi_yong_,
  799. zi_wai_deng_wai_j: item.zi_wai_deng_wai_j,
  800. kai_shi_shi_jian_: item.kai_shi_shi_jian_
  801. }
  802. })
  803. }
  804. await this.$common.request('add', params).then(() => { console.log('子表添加数据成功') })
  805. }
  806. if (updateList.length) {
  807. const params = {
  808. tableName: 't_sshjpzxq',
  809. updList: updateList.map(item => ({
  810. where: {
  811. zi_wai_deng_wai_j: item.zi_wai_deng_wai_j
  812. },
  813. param: {
  814. qu_yu_: item.qu_yu_,
  815. fang_jian_: item.fang_jian_,
  816. fang_jian_id_: item.fang_jian_id_,
  817. bu_men_: item.bu_men_,
  818. deviceno1_: item.deviceno1_,
  819. deviceid1_: item.deviceid1_,
  820. devicename1_: item.devicename1_,
  821. deviceno2_: item.deviceno2_, // 监控设备
  822. deviceid2_: item.deviceid2_,
  823. jian_ce_zhou_qi_: item.jian_ce_zhou_qi_,
  824. jian_ce_gang_wei_: item.jian_ce_gang_wei_,
  825. shi_fou_qi_yong_: item.shi_fou_qi_yong_,
  826. kong_zhi_tiao_jia: item.kong_zhi_tiao_jia,
  827. jian_ce_ri_qi_: item.jian_ce_ri_qi_,
  828. ri_qi_lie_biao_: item.ri_qi_lie_biao_,
  829. lie_biao_shu_ju_: item.lie_biao_shu_ju_,
  830. kai_shi_shi_jian_: item.kai_shi_shi_jian_
  831. }
  832. }))
  833. }
  834. await this.$common.request('update', params).then(() => { console.log('子表更新数据成功') })
  835. }
  836. if (deleteList.length) {
  837. const params = {
  838. tableName: 't_sshjpzxq',
  839. paramWhere: { zi_wai_deng_wai_j: deleteList.join(',') }
  840. }
  841. await this.$common.request('delete', params).then(() => { console.log('子表删除数据成功') })
  842. }
  843. this.$nextTick(() => {
  844. this.$message.success('修改成功!')
  845. this.closeDialog()
  846. })
  847. })
  848. } else {
  849. const params = {
  850. tableName: 't_sshjpzb',
  851. paramWhere: [{
  852. ...this.form
  853. }]
  854. }
  855. await this.$common.request('add', params).then(async (res) => {
  856. console.log('主表新增数据成功')
  857. const { cont = [] } = res.variables || {}
  858. if (addList.length) {
  859. const params = {
  860. tableName: 't_sshjpzxq',
  861. paramWhere: addList.map(item => {
  862. return {
  863. parent_id_: cont[0].id_,
  864. bu_men_: item.bu_men_,
  865. devicename1_: item.devicename1_,
  866. deviceno1_: item.deviceno1_,
  867. deviceid1_: item.deviceid1_,
  868. deviceno2_: item.deviceno2_,
  869. deviceid2_: item.deviceid2_,
  870. fang_jian_: item.fang_jian_,
  871. fang_jian_id_: item.fang_jian_id_,
  872. jian_ce_gang_wei_: item.jian_ce_gang_wei_,
  873. jian_ce_ri_qi_: item.jian_ce_ri_qi_,
  874. jian_ce_zhou_qi_: item.jian_ce_zhou_qi_,
  875. kong_zhi_tiao_jia: item.kong_zhi_tiao_jia,
  876. lie_biao_shu_ju_: item.lie_biao_shu_ju_,
  877. qu_yu_: item.qu_yu_,
  878. ri_qi_lie_biao_: item.ri_qi_lie_biao_,
  879. shi_fou_qi_yong_: item.shi_fou_qi_yong_,
  880. zi_wai_deng_wai_j: item.zi_wai_deng_wai_j,
  881. kai_shi_shi_jian_: item.kai_shi_shi_jian_
  882. }
  883. })
  884. }
  885. await this.$common.request('add', params).then(() => {
  886. this.$message.success('添加成功!')
  887. console.log('子表添加数据成功')
  888. this.closeDialog()
  889. })
  890. }
  891. })
  892. }
  893. // 紫外灯数据同步更新紫外灯消毒记录表
  894. if (this.form.lei_xing_.includes('12')) {
  895. const tableName = 't_jykzwdxdjlbsc'
  896. // 生成添加请求参数
  897. const addParams = addList.length ? {
  898. tableName,
  899. paramWhere: addList.map(item => ({
  900. di_dian_: this.level,
  901. bian_zhi_bu_men_: item.bu_men_,
  902. bian_zhi_ren_: this.userId,
  903. zi_wai_deng_ming_: item.devicename1_,
  904. she_shi_id_: item.zi_wai_deng_wai_j,
  905. gang_wei_: item.jian_ce_gang_wei_,
  906. shi_fou_ting_yong: item.shi_fou_qi_yong_
  907. }))
  908. } : null
  909. // 生成更新请求参数
  910. const updateParams = updateList.length ? {
  911. tableName,
  912. updList: updateList.map(item => ({
  913. where: {
  914. she_shi_id_: item.zi_wai_deng_wai_j
  915. },
  916. param: {
  917. bian_zhi_bu_men_: item.bu_men_,
  918. zi_wai_deng_ming_: item.devicename1_,
  919. gang_wei_: item.jian_ce_gang_wei_,
  920. shi_fou_ting_yong: item.shi_fou_qi_yong_
  921. }
  922. }))
  923. } : null
  924. // 生成删除请求参数
  925. const deleteParams = deleteList.length ? {
  926. tableName,
  927. paramWhere: { she_shi_id_: deleteList.join(',') }
  928. } : null
  929. // 合并所有请求
  930. const allRequests = []
  931. if (addParams) {
  932. allRequests.push(this.$common.request('add', addParams).then(() => console.log('添加紫外灯数据成功')))
  933. }
  934. if (updateParams) {
  935. allRequests.push(this.$common.request('update', updateParams).then(() => console.log('更新紫外灯数据成功')))
  936. }
  937. if (deleteParams) {
  938. allRequests.push(this.$common.request('delete', deleteParams).then(() => console.log('删除紫外灯数据成功')))
  939. }
  940. // 执行所有请求
  941. await Promise.all(allRequests)
  942. .then(() => console.log('所有请求完成'))
  943. .catch(error => console.error('请求出错:', error))
  944. }
  945. },
  946. saveResult () {
  947. this.$refs.form.validate((valid) => {
  948. if (valid) {
  949. this.submit()
  950. } else {
  951. this.$message.warning('请填写必填项')
  952. return false
  953. }
  954. })
  955. },
  956. // 查询
  957. goSearch () {
  958. console.log(this.search)
  959. if (!this.search.buMen && !this.search.quYu && !this.search.fangJian && !this.search.zhouQi && !this.search.gangWei) {
  960. this.isSearch = false
  961. } else {
  962. // 条件过滤
  963. const searchData = this.subForm
  964. .filter(item => item.bu_men_.indexOf(this.search.buMen) > -1)
  965. .filter(item => item.qu_yu_.indexOf(this.search.quYu) > -1)
  966. .filter(item => item.fang_jian_.indexOf(this.search.fangJian) > -1)
  967. .filter(item => item.jian_ce_zhou_qi_.indexOf(this.search.zhouQi) > -1)
  968. .filter(item => item.jian_ce_gang_wei_.indexOf(this.search.gangWei) > -1)
  969. this.isSearch = true
  970. this.searchData = searchData
  971. }
  972. }
  973. }
  974. }
  975. </script>
  976. <style lang="scss" scoped>
  977. .sub-dialog{
  978. .contain{
  979. padding: 20px;
  980. }
  981. }
  982. .paper-detail-dialog {
  983. ::v-deep {
  984. .el-dialog__header {
  985. text-align: center;
  986. }
  987. }
  988. .dialog-title{
  989. display: flex;
  990. align-items: center;
  991. justify-content: center;
  992. div{
  993. position: absolute;
  994. right:8vw;
  995. }
  996. .dialogtitle{
  997. font-size: 22px;
  998. font-family: SimHei;
  999. font-weight: bold;
  1000. color: #222;
  1001. }
  1002. }
  1003. .container {
  1004. display: flex;
  1005. width: 100%;
  1006. justify-content: center;
  1007. .el-row{
  1008. margin: 0 !important;
  1009. }
  1010. .required{
  1011. color: #606266 !important;
  1012. &::before{
  1013. content: '*';
  1014. margin: 0 4px 0 -7.5px;
  1015. color: #F56C6C;
  1016. }
  1017. }
  1018. .main{
  1019. width: 80%;
  1020. height: calc(100vh - 100px);
  1021. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  1022. padding:20px;
  1023. overflow-y: auto;
  1024. .form{
  1025. .el-row{
  1026. margin: 10px 0;
  1027. }
  1028. }
  1029. }
  1030. .table{
  1031. margin-top: 20px;
  1032. .el-alert{
  1033. margin-bottom: 20px;
  1034. }
  1035. .search{
  1036. display: flex;
  1037. flex-wrap: wrap;
  1038. align-items: center;
  1039. .search-item{
  1040. .label{
  1041. font-size: 12px;
  1042. min-width: 74px;
  1043. }
  1044. display: flex;
  1045. align-items: center;
  1046. width: 240px;
  1047. margin: 0 10px 8px 0;
  1048. }
  1049. }
  1050. }
  1051. }
  1052. }
  1053. ::v-deep {
  1054. .el-form-item__label{
  1055. text-align: left
  1056. }
  1057. .el-form-item__content{
  1058. font-size: 12px !important;
  1059. display: flex;
  1060. }
  1061. }
  1062. </style>