fecDialog.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021
  1. <template>
  2. <el-dialog
  3. :title="title + (isEdit === true ? '--编辑' : '--新增')"
  4. :visible.sync="dialogVisible"
  5. :close-on-click-modal="false"
  6. :close-on-press-escape="false"
  7. append-to-body
  8. class="dialog paper-detail-dialog"
  9. width="65%"
  10. top
  11. style="margin-top: 5vh"
  12. :show-close="false"
  13. >
  14. <div class="contain">
  15. <div class="main">
  16. <el-form ref="form" :model="form" label-width="120px">
  17. <el-row>
  18. <el-col :span="12">
  19. <el-form-item label="部门:">
  20. <template slot="label">
  21. <span class="required">部门:</span>
  22. </template>
  23. <ibps-user-selector
  24. v-model="form.bu_men_"
  25. size="mini"
  26. type="position"
  27. readonly-text="text"
  28. :disabled="false"
  29. :multiple="false"
  30. style="width: 80%"
  31. :filter="filter"
  32. filtrate
  33. />
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="12" v-if="!this.shouldShowColumn('deviceno3_')">
  37. <el-form-item label="监测岗位:">
  38. <template slot="label">
  39. <span class="required">监测岗位:</span>
  40. </template>
  41. <el-select
  42. v-model="form.jian_ce_gang_wei_"
  43. placeholder="请选择"
  44. size="mini"
  45. style="width: 80%"
  46. >
  47. <el-option
  48. v-for="item in monitoringpPosition"
  49. :key="item.positionId"
  50. :label="item.positionName"
  51. :value="item.positionName"
  52. />
  53. </el-select>
  54. </el-form-item>
  55. </el-col>
  56. </el-row>
  57. <el-row>
  58. <el-col :span="12">
  59. <el-form-item v-if="shouldRequired('fang_jian_')" label="房间:">
  60. <template slot="label">
  61. <span class="required">房间:</span>
  62. </template>
  63. <ibps-link-data
  64. v-model="form.fang_jian_"
  65. style="width: 80%"
  66. size="mini"
  67. template-key="fjzly"
  68. :multiple="false"
  69. :temp-search="true"
  70. label-key="fang_jian_ming_ha"
  71. value-key="fang_jian_ming_ha"
  72. :allow-create="false"
  73. :filterable="false"
  74. @change-link-data="fangJianChange"
  75. />
  76. </el-form-item>
  77. <el-form-item v-else label="房间:">
  78. <ibps-link-data
  79. v-model="form.fang_jian_"
  80. style="width: 80%"
  81. size="mini"
  82. template-key="fjzly"
  83. :multiple="false"
  84. :temp-search="true"
  85. label-key="fang_jian_ming_ha"
  86. value-key="fang_jian_ming_ha"
  87. :allow-create="false"
  88. :filterable="false"
  89. @change-link-data="fangJianChange"
  90. />
  91. </el-form-item>
  92. </el-col>
  93. <el-col v-show="form.qu_yu_" :span="12">
  94. <el-form-item label="区域:">
  95. <template slot="label">
  96. <span>区域</span>
  97. <el-tooltip
  98. effect="dark"
  99. content="区域由房间自动带出"
  100. placement="top"
  101. >
  102. <i class="el-icon-question question-icon">:</i>
  103. </el-tooltip>
  104. </template>
  105. <span>{{ form.qu_yu_ }}</span>
  106. </el-form-item>
  107. </el-col>
  108. </el-row>
  109. <el-row>
  110. <el-col :span="12">
  111. <el-form-item label="监控设备:">
  112. <ibps-link-data
  113. v-model="form.deviceno2_"
  114. style="width: 80%"
  115. size="mini"
  116. template-key="jksbxz"
  117. :multiple="false"
  118. :temp-search="true"
  119. label-key="deviceInfo"
  120. value-key="deviceInfo"
  121. :allow-create="false"
  122. :filterable="false"
  123. @change-link-data="deviceno2Change"
  124. />
  125. </el-form-item>
  126. </el-col>
  127. </el-row>
  128. <el-row v-if="shouldShowColumn('deviceno1_')">
  129. <el-col :span="12">
  130. <el-form-item
  131. v-if="shouldRequired('deviceno1_')"
  132. label="被控设备/设施编号:"
  133. label-width="140"
  134. >
  135. <template slot="label">
  136. <span class="required">被控设备/设施编号:</span>
  137. </template>
  138. <ibps-custom-dialog
  139. v-model="form.deviceno1_"
  140. size="mini"
  141. template-key="sbxzmcgl"
  142. :multiple="false"
  143. :disabled="false"
  144. type="dialog"
  145. class="custom-dialog"
  146. placeholder="请选择设备"
  147. icon="el-icon-search"
  148. style="width: 80%"
  149. @change-link-data="deviceno1Change"
  150. />
  151. </el-form-item>
  152. <el-form-item
  153. v-else
  154. label="被控设备/设施编号:"
  155. label-width="140"
  156. >
  157. <ibps-link-data
  158. v-model="form.deviceno1_"
  159. style="width: 80%"
  160. size="mini"
  161. template-key="sbxzsshj"
  162. :multiple="false"
  163. :temp-search="true"
  164. label-key="yuan_she_bei_bian"
  165. value-key="yuan_she_bei_bian"
  166. :allow-create="false"
  167. :filterable="false"
  168. @change-link-data="deviceno1Change"
  169. />
  170. </el-form-item>
  171. </el-col>
  172. <el-col v-show="form.deviceno1_" :span="12">
  173. <el-form-item
  174. v-if="shouldRequired('devicename1_')"
  175. label="被控设备/设施名称:"
  176. label-width="140"
  177. >
  178. <template slot="label">
  179. <span>被控设备/设施名称</span>
  180. <el-tooltip
  181. effect="dark"
  182. content="选择设备后自动带出名称"
  183. placement="top"
  184. >
  185. <i class="el-icon-question question-icon">:</i>
  186. </el-tooltip>
  187. </template>
  188. <div>{{ form.devicename1_ }}</div>
  189. </el-form-item>
  190. <el-form-item
  191. v-else
  192. label="被控设备/设施名称:"
  193. label-width="140"
  194. >
  195. <el-input
  196. v-model="form.devicename1_"
  197. size="mini"
  198. style="width: 80%"
  199. />
  200. </el-form-item>
  201. </el-col>
  202. </el-row>
  203. <el-row v-if="shouldShowColumn('deviceno3_')">
  204. <el-col :span="12">
  205. <el-form-item label="被控试剂/耗材:" label-width="140">
  206. <template slot="label">
  207. <span class="required">被控试剂/耗材:</span>
  208. </template>
  209. <ibps-custom-dialog
  210. v-model="form.deviceno1_"
  211. size="mini"
  212. template-key="sjhcjcsjdhkbm"
  213. :multiple="false"
  214. :disabled="false"
  215. type="dialog"
  216. class="custom-dialog"
  217. placeholder="请选择试剂/耗材"
  218. icon="el-icon-search"
  219. style="width: 80%"
  220. @change-link-data="deviceno1Change"
  221. />
  222. </el-form-item>
  223. </el-col>
  224. <el-col v-show="form.deviceno1_" :span="12">
  225. <el-form-item label="试剂/耗材名称:" label-width="140">
  226. <template slot="label">
  227. <span>试剂/耗材名称</span>
  228. <el-tooltip
  229. effect="dark"
  230. content="选择试剂/耗材后自动带出名称"
  231. placement="top"
  232. >
  233. <i class="el-icon-question question-icon">:</i>
  234. </el-tooltip>
  235. </template>
  236. <div>{{ form.devicename1_ }}</div>
  237. </el-form-item>
  238. </el-col>
  239. </el-row>
  240. <el-row v-if="!shouldShowColumn('deviceno3_')">
  241. <el-col :span="12">
  242. <el-form-item label="监测周期:">
  243. <template slot="label">
  244. <span class="required">监测周期:</span>
  245. </template>
  246. <el-select
  247. v-model="form.jian_ce_zhou_qi_"
  248. placeholder="请选择"
  249. size="mini"
  250. style="width: 80%"
  251. >
  252. <el-option
  253. v-for="item in period"
  254. :key="item.value"
  255. :label="item.label"
  256. :value="item.value"
  257. />
  258. </el-select>
  259. </el-form-item>
  260. </el-col>
  261. <el-col :span="12">
  262. <el-form-item label="是否启用:">
  263. <template slot="label">
  264. <span>是否启用</span>
  265. <el-tooltip
  266. effect="dark"
  267. content="若该值为停用时,将不会按监测周期产生对应记录。"
  268. placement="top"
  269. >
  270. <i class="el-icon-question question-icon">:</i>
  271. </el-tooltip>
  272. </template>
  273. <div class="qiyong">
  274. <el-radio v-model="form.shi_fou_qi_yong_" label="1"
  275. >启用</el-radio
  276. >
  277. <el-radio v-model="form.shi_fou_qi_yong_" label="0"
  278. >停用</el-radio
  279. >
  280. </div>
  281. </el-form-item>
  282. </el-col>
  283. </el-row>
  284. <el-row
  285. v-if="
  286. form.jian_ce_zhou_qi_ !== '' && form.jian_ce_zhou_qi_ !== '按需'
  287. "
  288. >
  289. <el-col :span="12">
  290. <el-form-item :label="labelShow">
  291. <template slot="label">
  292. <span class="required">{{ labelShow }}</span>
  293. </template>
  294. <el-checkbox-group
  295. v-if="form.jian_ce_zhou_qi_ === '每日'"
  296. v-model="dayCheck"
  297. size="mini"
  298. >
  299. <el-checkbox
  300. v-for="item in weekDays"
  301. :key="item.value"
  302. :label="item.value"
  303. size="mini"
  304. >{{ item.label }}</el-checkbox
  305. >
  306. </el-checkbox-group>
  307. <template v-if="form.jian_ce_zhou_qi_ === '每周'">
  308. <div class="radio" style="width: 100%">
  309. <el-radio
  310. v-for="item in weekDays"
  311. :key="item.value"
  312. v-model="weekCheck"
  313. :label="item.value"
  314. size="mini"
  315. >{{ item.label }}</el-radio
  316. >
  317. </div>
  318. </template>
  319. <el-select
  320. v-if="form.jian_ce_zhou_qi_ === '每月'"
  321. v-model="monthCheck"
  322. placeholder="请选择"
  323. size="mini"
  324. style="width: 80%"
  325. >
  326. <el-option
  327. v-for="item in 28"
  328. :key="item"
  329. :label="`第${item}天`"
  330. :value="item"
  331. />
  332. </el-select>
  333. <el-select
  334. v-if="form.jian_ce_zhou_qi_ === '每季度'"
  335. v-model="quarterCheck"
  336. placeholder="请选择"
  337. size="mini"
  338. style="width: 80%"
  339. >
  340. <el-option
  341. v-for="item in 3"
  342. :key="item"
  343. :label="`第${item}个月`"
  344. :value="item"
  345. />
  346. </el-select>
  347. <el-select
  348. v-if="form.jian_ce_zhou_qi_ === '每半年'"
  349. v-model="halfYearCheck"
  350. placeholder="请选择"
  351. size="mini"
  352. style="width: 80%"
  353. >
  354. <el-option
  355. v-for="item in 6"
  356. :key="item"
  357. :label="`第${item}个月`"
  358. :value="item"
  359. />
  360. </el-select>
  361. <el-select
  362. v-if="form.jian_ce_zhou_qi_ === '每年'"
  363. v-model="yearCheck"
  364. placeholder="请选择"
  365. size="mini"
  366. style="width: 80%"
  367. >
  368. <el-option
  369. v-for="item in 12"
  370. :key="item"
  371. :label="`第${item}个月`"
  372. :value="item"
  373. />
  374. </el-select>
  375. <el-select
  376. v-if="form.jian_ce_zhou_qi_ === '间隔'"
  377. v-model="sepCheck"
  378. placeholder="请选择"
  379. size="mini"
  380. style="width: 80%"
  381. >
  382. <el-option
  383. v-for="item in 30"
  384. :key="item"
  385. :label="`每隔${item}天`"
  386. :value="item"
  387. />
  388. </el-select>
  389. </el-form-item>
  390. </el-col>
  391. <el-col v-if="nextDate" :span="12">
  392. <el-form-item label="下次监测日期为:">
  393. <el-tag size="mini" class="eltag">{{ nextDate }}</el-tag>
  394. </el-form-item>
  395. </el-col>
  396. <el-col v-if="form.jian_ce_zhou_qi_ === '间隔'" :span="12">
  397. <el-form-item label="开始监测时间:" prop="">
  398. <el-date-picker
  399. v-model="form.kai_shi_shi_jian_"
  400. :clearable="false"
  401. type="date"
  402. placeholder="选择监测开始时间"
  403. :picker-options="pickerOptions"
  404. value-format="yyyy-MM-dd"
  405. size="mini"
  406. style="width: 80%"
  407. />
  408. </el-form-item>
  409. </el-col>
  410. </el-row>
  411. <el-row>
  412. <el-col :span="12">
  413. <el-form-item label="控制条件:">
  414. <el-input
  415. v-model="form.kong_zhi_tiao_jia"
  416. type="textarea"
  417. :rows="2"
  418. size="mini"
  419. style="width: 80%"
  420. />
  421. </el-form-item>
  422. </el-col>
  423. <el-col :span="12">
  424. <el-form-item label="控制标准:">
  425. <el-input
  426. v-model="form.kong_zhi_biao_zhu"
  427. type="textarea"
  428. :rows="2"
  429. size="mini"
  430. style="width: 80%"
  431. />
  432. </el-form-item>
  433. </el-col>
  434. </el-row>
  435. <el-row>
  436. <el-col :span="24">
  437. <FacilityData
  438. v-if="form.lie_biao_shu_ju_"
  439. :is-cul="false"
  440. :form-data="{ lieBiaoShuJu: form.lie_biao_shu_ju_ }"
  441. @change-data="onFacilityData"
  442. />
  443. </el-col>
  444. </el-row>
  445. </el-form>
  446. </div>
  447. </div>
  448. <span slot="footer" class="dialog-footer">
  449. <el-button
  450. type="primary"
  451. icon="ibps-icon-save"
  452. size="mini"
  453. @click="submit"
  454. >确 定</el-button
  455. >
  456. <el-button icon="ibps-icon-close" type="danger" size="mini" @click="close"
  457. >取 消</el-button
  458. >
  459. </span>
  460. </el-dialog>
  461. </template>
  462. <script>
  463. import ibpsUserSelector from '@/business/platform/org/selector'
  464. import IbpsLinkData from '@/business/platform/data/templaterender/link-data'
  465. import FacilityData from '@/views/component/facility/facilityData.vue'
  466. export default {
  467. components: {
  468. FacilityData,
  469. ibpsUserSelector,
  470. IbpsLinkData,
  471. IbpsCustomDialog: () =>
  472. import('@/business/platform/data/templaterender/custom-dialog')
  473. },
  474. data() {
  475. return {
  476. pickerOptions: {
  477. disabledDate(time) {
  478. return time.getTime() < Date.now() - 24 * 60 * 1000 * 60
  479. }
  480. },
  481. weekDays: [
  482. { label: '周一', value: 1 },
  483. { label: '周二', value: 2 },
  484. { label: '周三', value: 3 },
  485. { label: '周四', value: 4 },
  486. { label: '周五', value: 5 },
  487. { label: '周六', value: 6 },
  488. { label: '周日', value: 7 }
  489. ],
  490. filter: [
  491. {
  492. descVal: '1',
  493. includeSub: true,
  494. old: 'position',
  495. partyId: this.$store.getters.userInfo.employee.positions,
  496. partyName: '',
  497. scriptContent: '',
  498. type: 'user',
  499. userType: 'position'
  500. }
  501. ],
  502. dialogVisible: true,
  503. title: '配置详情',
  504. jianCeGangWeiList: [],
  505. lei_xing_: '',
  506. form: {
  507. qu_yu_: '',
  508. fang_jian_: '',
  509. fang_jian_id_: '',
  510. bu_men_: '',
  511. deviceno1_: '',
  512. deviceid1_: '', // 设备id
  513. devicename1_: '',
  514. deviceno2_: '', // 监控设备
  515. deviceid2_: '', // 监控设备id
  516. jian_ce_zhou_qi_: '',
  517. jian_ce_gang_wei_: '',
  518. shi_fou_qi_yong_: '1',
  519. kong_zhi_tiao_jia: '',
  520. kong_zhi_biao_zhu: '',
  521. jian_ce_ri_qi_: '',
  522. ri_qi_lie_biao_: '',
  523. zi_wai_deng_wai_j: '', // 紫外灯外键
  524. lie_biao_shu_ju_: '',
  525. kai_shi_shi_jian_: ''
  526. },
  527. isEdit: false,
  528. nextDate: '',
  529. dayCheck: [],
  530. weekCheck: '',
  531. monthCheck: '',
  532. quarterCheck: '',
  533. halfYearCheck: '',
  534. yearCheck: '',
  535. sepCheck: '',
  536. period: [
  537. { label: '日监测', value: '每日' },
  538. { label: '周监测', value: '每周' },
  539. { label: '月监测', value: '每月' },
  540. { label: '季度监测', value: '每季度' },
  541. { label: '半年监测', value: '每半年' },
  542. { label: '年监测', value: '每年' },
  543. { label: '按时间间隔监测', value: '间隔' },
  544. { label: '按需监测', value: '按需' }
  545. ],
  546. config: {}
  547. }
  548. },
  549. computed: {
  550. monitoringpPosition() {
  551. return this.jianCeGangWeiList.filter((i) => i.dept === this.form.bu_men_)
  552. },
  553. shouldShowColumn() {
  554. return (columnName) => {
  555. return this.config[this.lei_xing_]?.displayField?.includes(columnName)
  556. }
  557. },
  558. shouldRequired() {
  559. return (columnName) => {
  560. return this.config[this.lei_xing_]?.requireField?.includes(columnName)
  561. }
  562. },
  563. labelShow() {
  564. if (this.form.jian_ce_zhou_qi_) {
  565. if (this.form.jian_ce_zhou_qi_ !== '间隔') {
  566. return this.form.jian_ce_zhou_qi_.split('每')[1] + '监测日期:'
  567. }
  568. return '间隔时间:'
  569. }
  570. return ''
  571. }
  572. },
  573. watch: {
  574. 'form.jian_ce_zhou_qi_'(val, old) {
  575. if (!old) return
  576. this.dayCheck = []
  577. this.weekCheck = ''
  578. this.monthCheck = ''
  579. this.quarterCheck = ''
  580. this.halfYearCheck = ''
  581. this.yearCheck = ''
  582. this.sepCheck = ''
  583. this.nextDate = ''
  584. this.form.kai_shi_shi_jian_ = ''
  585. },
  586. dayCheck: {
  587. handler: function (val, oldVal) {
  588. if (val.length === 0) {
  589. this.nextDate = ''
  590. return
  591. }
  592. const temp_val = JSON.parse(JSON.stringify(val))
  593. const today = new Date()
  594. temp_val.sort(function (a, b) {
  595. return a - b
  596. })
  597. const num = temp_val.findIndex((e) => e > today.getDay())
  598. if (temp_val.length > 0 && num !== -1) {
  599. this.nextDate = this.getDayDate(temp_val[num], 0)
  600. } else if (temp_val.length > 0 && num === -1) {
  601. this.nextDate = this.getDayDate(temp_val[0], 1)
  602. } else {
  603. this.nextDate = ''
  604. }
  605. },
  606. immediate: true
  607. },
  608. weekCheck: {
  609. handler: function (val, oldVal) {
  610. if (val === '') {
  611. this.nextDate = ''
  612. return
  613. }
  614. const today = new Date()
  615. const weekNum = []
  616. weekNum.push(val)
  617. const num = weekNum.findIndex((e) => e > today.getDay())
  618. if (val !== '' && num !== -1) {
  619. this.nextDate = this.getDayDate(weekNum[0], 0)
  620. } else if (val !== '' && num === -1) {
  621. this.nextDate = this.getDayDate(weekNum[0], 1)
  622. } else {
  623. this.nextDate = ''
  624. }
  625. },
  626. immediate: true
  627. },
  628. monthCheck: {
  629. handler: function (val, oldVal) {
  630. if (val === '') {
  631. this.nextDate = ''
  632. return
  633. }
  634. const today = new Date()
  635. const day = today.getDate()
  636. const nextMonth = this.getNextMonthDate(today, val, 1)
  637. const currentMonth = this.getNextMonthDate(today, val, 0)
  638. this.nextDate = val > day ? currentMonth : nextMonth
  639. }
  640. // immediate: true
  641. },
  642. quarterCheck: {
  643. handler: function (val, oldVal) {
  644. if (val === '') {
  645. this.nextDate = ''
  646. return
  647. }
  648. const quarterList = [
  649. [1, 2, 3],
  650. [4, 5, 6],
  651. [7, 8, 9],
  652. [10, 11, 12]
  653. ]
  654. const today = new Date()
  655. const month = today.getMonth() + 1
  656. const qu = this.getQuarter(today)
  657. const nowM = quarterList[qu - 1][val - 1]
  658. const nextM = quarterList[qu % 4][val - 1]
  659. const endMonth = month >= nowM ? nextM : nowM
  660. const yearPJ = today.getFullYear()
  661. const monthPJ = endMonth > 9 ? endMonth : '0' + endMonth
  662. this.nextDate = yearPJ + '-' + monthPJ + '-01'
  663. }
  664. // immediate: true
  665. },
  666. halfYearCheck: {
  667. handler: function (val, oldVal) {
  668. if (val === '') {
  669. this.nextDate = ''
  670. return
  671. }
  672. const midList = [
  673. [1, 2, 3, 4, 5, 6],
  674. [7, 8, 9, 10, 11, 12]
  675. ]
  676. const today = new Date()
  677. const month = today.getMonth() + 1
  678. const qu = month > 6 ? 2 : 1
  679. const nowM = midList[qu - 1][val - 1]
  680. const nextM = midList[qu % 2][val - 1]
  681. const endMonth = month >= nowM ? nextM : nowM
  682. const yearPJ =
  683. month >= nowM ? today.getFullYear() + 1 : today.getFullYear()
  684. const monthPJ = endMonth > 9 ? endMonth : '0' + endMonth
  685. this.nextDate = yearPJ + '-' + monthPJ + '-01'
  686. }
  687. // immediate: true
  688. },
  689. yearCheck: {
  690. handler: function (val, oldVal) {
  691. if (val === '') {
  692. this.nextDate = ''
  693. return
  694. }
  695. const today = new Date()
  696. const month = today.getMonth() + 1
  697. const year = today.getFullYear()
  698. const qu = month >= val ? year + 1 : year
  699. const monthPJ = val > 9 ? val : '0' + val
  700. this.nextDate = qu + '-' + monthPJ + '-01'
  701. }
  702. // immediate: true
  703. }
  704. },
  705. methods: {
  706. deviceno1Change(key, data) {
  707. this.form.deviceid1_ = data.id_ || ''
  708. this.form.devicename1_ =
  709. data.she_bei_ming_cheng_ || data.ming_cheng_ || ''
  710. },
  711. deviceno2Change(key, data) {
  712. this.form.deviceid2_ = data.deviceId || ''
  713. },
  714. fangJianChange(key, data) {
  715. this.form.fang_jian_id_ = data.id_ || ''
  716. this.form.qu_yu_ = data.qu_yu_ || ''
  717. this.form.kong_zhi_biao_zhu = data.kong_zhi_biao_zhu || ''
  718. },
  719. // 接收自定义组件数据
  720. onFacilityData(...arg) {
  721. if (arg.length > 1) {
  722. this.form.lie_biao_shu_ju_ = arg[1]
  723. }
  724. },
  725. // 格式化数据
  726. formatForm() {
  727. // 监测日期格式化
  728. switch (this.form.jian_ce_zhou_qi_) {
  729. case '每日':
  730. if (!this.dayCheck || this.dayCheck.length === 0) {
  731. this.form.jian_ce_ri_qi_ = ''
  732. this.form.ri_qi_lie_biao_ = ''
  733. } else if (this.dayCheck.length === 7) {
  734. this.form.jian_ce_ri_qi_ = '每天'
  735. this.form.ri_qi_lie_biao_ = '1,2,3,4,5,6,7'
  736. } else {
  737. this.dayCheck.sort(function (a, b) {
  738. return a - b
  739. })
  740. this.form.jian_ce_ri_qi_ = '每周' + this.dayCheck.join(',')
  741. this.form.ri_qi_lie_biao_ = this.dayCheck.join(',')
  742. }
  743. break
  744. case '每周':
  745. if (this.weekCheck) {
  746. this.form.jian_ce_ri_qi_ = '每周' + this.weekCheck
  747. this.form.ri_qi_lie_biao_ = this.weekCheck + ''
  748. } else {
  749. this.form.jian_ce_ri_qi_ = ''
  750. this.form.ri_qi_lie_biao_ = ''
  751. }
  752. break
  753. case '每月':
  754. if (this.monthCheck) {
  755. this.form.jian_ce_ri_qi_ = '每个月第' + this.monthCheck + '天'
  756. this.form.ri_qi_lie_biao_ = this.monthCheck + ''
  757. } else {
  758. this.form.jian_ce_ri_qi_ = ''
  759. this.form.ri_qi_lie_biao_ = ''
  760. }
  761. break
  762. case '每季度':
  763. if (this.quarterCheck) {
  764. this.form.jian_ce_ri_qi_ = '每季度第' + [this.quarterCheck] + '个月'
  765. this.form.ri_qi_lie_biao_ = this.quarterCheck + ''
  766. } else {
  767. this.form.jian_ce_ri_qi_ = ''
  768. this.form.ri_qi_lie_biao_ = ''
  769. }
  770. break
  771. case '每半年':
  772. if (this.halfYearCheck) {
  773. this.form.jian_ce_ri_qi_ =
  774. '每半年第' + [this.halfYearCheck] + '个月'
  775. this.form.ri_qi_lie_biao_ = this.halfYearCheck + ''
  776. } else {
  777. this.form.jian_ce_ri_qi_ = ''
  778. this.form.ri_qi_lie_biao_ = ''
  779. }
  780. break
  781. case '每年':
  782. if (this.yearCheck) {
  783. this.form.jian_ce_ri_qi_ = '每年第' + [this.yearCheck] + '个月'
  784. this.form.ri_qi_lie_biao_ = this.yearCheck + ''
  785. } else {
  786. this.form.jian_ce_ri_qi_ = ''
  787. this.form.ri_qi_lie_biao_ = ''
  788. }
  789. break
  790. case '间隔':
  791. if (this.sepCheck && this.form.kai_shi_shi_jian_) {
  792. this.form.jian_ce_ri_qi_ =
  793. this.form.kai_shi_shi_jian_ + '起每隔' + this.sepCheck + '天'
  794. this.form.ri_qi_lie_biao_ = this.sepCheck + ''
  795. } else {
  796. this.form.jian_ce_ri_qi_ = ''
  797. this.form.ri_qi_lie_biao_ = ''
  798. }
  799. break
  800. case '按需':
  801. this.form.jian_ce_ri_qi_ = '按需'
  802. break
  803. default:
  804. break
  805. }
  806. },
  807. checkForm() {
  808. if (this.form.bu_men_ === '') {
  809. throw new Error('部门信息缺失!')
  810. }
  811. if (
  812. this.form.jian_ce_ri_qi_ === '' &&
  813. this.form.jian_ce_zhou_qi_ !== '按需' &&
  814. !this.shouldShowColumn('deviceno3_')
  815. ) {
  816. throw new Error('监测日期信息缺失!')
  817. }
  818. if (
  819. this.form.jian_ce_gang_wei_ === '' &&
  820. !this.shouldShowColumn('deviceno3_')
  821. ) {
  822. throw new Error('监测岗位信息缺失!')
  823. }
  824. if (this.shouldRequired('deviceno1_') && this.form.deviceno1_ === '') {
  825. throw new Error('请先选择设备或试剂耗材!')
  826. }
  827. if (this.shouldRequired('fang_jian_') && this.form.fang_jian_ === '') {
  828. throw new Error('请先选择房间!')
  829. }
  830. if (this.form.lie_biao_shu_ju_) {
  831. const lie_biao_shu_ju_ = JSON.parse(this.form.lie_biao_shu_ju_)
  832. for (let i = 0; i < lie_biao_shu_ju_.length; i++) {
  833. const item = lie_biao_shu_ju_[i]
  834. if (
  835. !item.label &&
  836. (item.range.length !== 2 ||
  837. item.range[0] === null ||
  838. item.range[1] === null) &&
  839. !item.fixValue &&
  840. !item.unit
  841. ) {
  842. throw new Error(`第${i + 1}行数据非法!`)
  843. }
  844. }
  845. }
  846. },
  847. submit() {
  848. try {
  849. this.formatForm()
  850. this.checkForm()
  851. this.$emit('onSubmit', { form: this.form, isEdit: this.isEdit })
  852. } catch (error) {
  853. this.$message.warning(error.message)
  854. }
  855. },
  856. close() {
  857. this.$emit('onClose')
  858. },
  859. // 格式化监测日期
  860. formatData() {
  861. if (this.form.jian_ce_ri_qi_) {
  862. this.$nextTick(() => {
  863. switch (this.form.jian_ce_zhou_qi_) {
  864. case '每日':
  865. if (this.form.jian_ce_ri_qi_ === '每天') {
  866. this.dayCheck = [1, 2, 3, 4, 5, 6, 7]
  867. } else {
  868. this.dayCheck = this.form.jian_ce_ri_qi_
  869. .split('每周')[1]
  870. .split(',')
  871. .map((item) => +item)
  872. }
  873. break
  874. case '每周':
  875. this.weekCheck = +this.form.jian_ce_ri_qi_.split('每周')[1]
  876. break
  877. case '每月':
  878. this.monthCheck = +this.form.jian_ce_ri_qi_
  879. .split('每个月第')[1]
  880. .split('天')[0]
  881. break
  882. case '每季度':
  883. this.quarterCheck = +this.form.jian_ce_ri_qi_
  884. .split('每季度第')[1]
  885. .split('个月')[0]
  886. break
  887. case '每半年':
  888. this.halfYearCheck = +this.form.jian_ce_ri_qi_
  889. .split('每半年第')[1]
  890. .split('个月')[0]
  891. break
  892. case '每年':
  893. this.yearCheck = +this.form.jian_ce_ri_qi_
  894. .split('每年第')[1]
  895. .split('个月')[0]
  896. break
  897. case '间隔':
  898. this.sepCheck = +this.form.ri_qi_lie_biao_
  899. break
  900. default:
  901. break
  902. }
  903. })
  904. }
  905. },
  906. open(row, jianCeGangWeiList, parentForm, config) {
  907. this.dialogVisible = true
  908. this.jianCeGangWeiList = jianCeGangWeiList
  909. this.lei_xing_ = parentForm.lei_xing_
  910. this.config = config
  911. this.isEdit = !!(row && row.zi_wai_deng_wai_j)
  912. // 编辑
  913. if (this.isEdit) {
  914. // this.form = JSON.parse(JSON.stringify(row))
  915. const temp = JSON.parse(JSON.stringify(row))
  916. Object.assign(this.form, temp)
  917. } else {
  918. this.form.zi_wai_deng_wai_j = this.$utils.guid()
  919. this.form.bu_men_ = parentForm.bian_zhi_bu_men_
  920. this.form.jian_ce_gang_wei_ = parentForm.gang_wei_
  921. this.form.jian_ce_ri_qi_ = parentForm.jian_ce_ri_qi_
  922. this.form.kong_zhi_tiao_jia = parentForm.tiao_jian_
  923. this.form.kong_zhi_biao_zhu = parentForm.kong_zhi_biao_zhu
  924. this.form.jian_ce_zhou_qi_ = parentForm.zhou_qi_
  925. this.form.ri_qi_lie_biao_ = parentForm.ri_qi_lie_biao_
  926. this.form.lie_biao_shu_ju_ = parentForm.lie_biao_shu_ju_
  927. this.form.kai_shi_shi_jian_ = parentForm.kai_shi_shi_jian_
  928. }
  929. this.formatData()
  930. },
  931. getDayDate(type, dates) {
  932. const now = new Date()
  933. const nowTime = now.getTime()
  934. const day = now.getDay()
  935. const longTime = 24 * 60 * 60 * 1000
  936. const n = longTime * 7 * (dates || 0)
  937. let dd = nowTime - (day - type) * longTime + n
  938. dd = new Date(dd)
  939. const y = dd.getFullYear()
  940. let m = dd.getMonth() + 1
  941. let d = dd.getDate()
  942. m = m < 10 ? '0' + m : m
  943. d = d < 10 ? '0' + d : d
  944. const daynow = y + '-' + m + '-' + d
  945. return daynow
  946. },
  947. // 获取往后几个月相应的日期
  948. // currentDate:当前日期
  949. // dayOfMonth:获取几号
  950. // val:往后几个月
  951. getNextMonthDate(currentDate, dayOfMonth, val) {
  952. const currentYear = currentDate.getFullYear()
  953. const currentMonth = currentDate.getMonth()
  954. const nextMonth = currentMonth + val
  955. const nextMonthDate = new Date(currentYear, nextMonth, dayOfMonth)
  956. const formattedDate = nextMonthDate
  957. .toLocaleString('zh-CN', {
  958. year: 'numeric',
  959. month: '2-digit',
  960. day: '2-digit'
  961. })
  962. .replace(/\//g, '-')
  963. return formattedDate
  964. },
  965. // 获取当前季度
  966. getQuarter(date) {
  967. return Math.floor(date.getMonth() / 3) + 1
  968. }
  969. }
  970. }
  971. </script>
  972. <style lang="scss">
  973. .contain {
  974. .main {
  975. padding: 20px;
  976. height: 60vh;
  977. .qiyong {
  978. margin-top: 0px;
  979. }
  980. .el-row {
  981. margin: 10px 0;
  982. }
  983. .required {
  984. color: #606266 !important;
  985. &::before {
  986. content: '*';
  987. margin: 0 4px 0 -7.5px;
  988. color: #f56c6c;
  989. }
  990. }
  991. .eltag {
  992. margin-top: 6px;
  993. }
  994. }
  995. .el-row {
  996. margin: 0 !important;
  997. }
  998. .question-icon {
  999. margin-left: 2px;
  1000. }
  1001. }
  1002. .dialog-footer {
  1003. display: flex;
  1004. justify-content: center;
  1005. }
  1006. ::v-deep {
  1007. .el-form-item__label {
  1008. text-align: left;
  1009. }
  1010. }
  1011. </style>