fecDialog.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  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">
  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>
  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. ) {
  815. throw new Error('监测日期信息缺失!')
  816. }
  817. if (this.form.jian_ce_gang_wei_ === '') {
  818. throw new Error('监测岗位信息缺失!')
  819. }
  820. if (this.shouldRequired('deviceno1_') && this.form.deviceno1_ === '') {
  821. throw new Error('请先选择设备或试剂耗材!')
  822. }
  823. if (this.shouldRequired('fang_jian_') && this.form.fang_jian_ === '') {
  824. throw new Error('请先选择房间!')
  825. }
  826. if (this.form.lie_biao_shu_ju_) {
  827. const lie_biao_shu_ju_ = JSON.parse(this.form.lie_biao_shu_ju_)
  828. for (let i = 0; i < lie_biao_shu_ju_.length; i++) {
  829. const item = lie_biao_shu_ju_[i]
  830. if (
  831. !item.label &&
  832. (item.range.length !== 2 ||
  833. item.range[0] === null ||
  834. item.range[1] === null) &&
  835. !item.fixValue &&
  836. !item.unit
  837. ) {
  838. throw new Error(`第${i + 1}行数据非法!`)
  839. }
  840. }
  841. }
  842. },
  843. submit() {
  844. try {
  845. this.formatForm()
  846. this.checkForm()
  847. this.$emit('onSubmit', { form: this.form, isEdit: this.isEdit })
  848. } catch (error) {
  849. this.$message.warning(error.message)
  850. }
  851. },
  852. close() {
  853. this.$emit('onClose')
  854. },
  855. // 格式化监测日期
  856. formatData() {
  857. if (this.form.jian_ce_ri_qi_) {
  858. this.$nextTick(() => {
  859. switch (this.form.jian_ce_zhou_qi_) {
  860. case '每日':
  861. if (this.form.jian_ce_ri_qi_ === '每天') {
  862. this.dayCheck = [1, 2, 3, 4, 5, 6, 7]
  863. } else {
  864. this.dayCheck = this.form.jian_ce_ri_qi_
  865. .split('每周')[1]
  866. .split(',')
  867. .map((item) => +item)
  868. }
  869. break
  870. case '每周':
  871. this.weekCheck = +this.form.jian_ce_ri_qi_.split('每周')[1]
  872. break
  873. case '每月':
  874. this.monthCheck = +this.form.jian_ce_ri_qi_
  875. .split('每个月第')[1]
  876. .split('天')[0]
  877. break
  878. case '每季度':
  879. this.quarterCheck = +this.form.jian_ce_ri_qi_
  880. .split('每季度第')[1]
  881. .split('个月')[0]
  882. break
  883. case '每半年':
  884. this.halfYearCheck = +this.form.jian_ce_ri_qi_
  885. .split('每半年第')[1]
  886. .split('个月')[0]
  887. break
  888. case '每年':
  889. this.yearCheck = +this.form.jian_ce_ri_qi_
  890. .split('每年第')[1]
  891. .split('个月')[0]
  892. break
  893. case '间隔':
  894. this.sepCheck = +this.form.ri_qi_lie_biao_
  895. break
  896. default:
  897. break
  898. }
  899. })
  900. }
  901. },
  902. open(row, jianCeGangWeiList, parentForm, config) {
  903. this.dialogVisible = true
  904. this.jianCeGangWeiList = jianCeGangWeiList
  905. this.lei_xing_ = parentForm.lei_xing_
  906. this.config = config
  907. this.isEdit = !!(row && row.zi_wai_deng_wai_j)
  908. // 编辑
  909. if (this.isEdit) {
  910. // this.form = JSON.parse(JSON.stringify(row))
  911. const temp = JSON.parse(JSON.stringify(row))
  912. Object.assign(this.form, temp)
  913. } else {
  914. this.form.zi_wai_deng_wai_j = this.$utils.guid()
  915. this.form.bu_men_ = parentForm.bian_zhi_bu_men_
  916. this.form.jian_ce_gang_wei_ = parentForm.gang_wei_
  917. this.form.jian_ce_ri_qi_ = parentForm.jian_ce_ri_qi_
  918. this.form.kong_zhi_tiao_jia = parentForm.tiao_jian_
  919. this.form.kong_zhi_biao_zhu = parentForm.kong_zhi_biao_zhu
  920. this.form.jian_ce_zhou_qi_ = parentForm.zhou_qi_
  921. this.form.ri_qi_lie_biao_ = parentForm.ri_qi_lie_biao_
  922. this.form.lie_biao_shu_ju_ = parentForm.lie_biao_shu_ju_
  923. this.form.kai_shi_shi_jian_ = parentForm.kai_shi_shi_jian_
  924. }
  925. this.formatData()
  926. },
  927. getDayDate(type, dates) {
  928. const now = new Date()
  929. const nowTime = now.getTime()
  930. const day = now.getDay()
  931. const longTime = 24 * 60 * 60 * 1000
  932. const n = longTime * 7 * (dates || 0)
  933. let dd = nowTime - (day - type) * longTime + n
  934. dd = new Date(dd)
  935. const y = dd.getFullYear()
  936. let m = dd.getMonth() + 1
  937. let d = dd.getDate()
  938. m = m < 10 ? '0' + m : m
  939. d = d < 10 ? '0' + d : d
  940. const daynow = y + '-' + m + '-' + d
  941. return daynow
  942. },
  943. // 获取往后几个月相应的日期
  944. // currentDate:当前日期
  945. // dayOfMonth:获取几号
  946. // val:往后几个月
  947. getNextMonthDate(currentDate, dayOfMonth, val) {
  948. const currentYear = currentDate.getFullYear()
  949. const currentMonth = currentDate.getMonth()
  950. const nextMonth = currentMonth + val
  951. const nextMonthDate = new Date(currentYear, nextMonth, dayOfMonth)
  952. const formattedDate = nextMonthDate
  953. .toLocaleString('zh-CN', {
  954. year: 'numeric',
  955. month: '2-digit',
  956. day: '2-digit'
  957. })
  958. .replace(/\//g, '-')
  959. return formattedDate
  960. },
  961. // 获取当前季度
  962. getQuarter(date) {
  963. return Math.floor(date.getMonth() / 3) + 1
  964. }
  965. }
  966. }
  967. </script>
  968. <style lang="scss">
  969. .contain {
  970. .main {
  971. padding: 20px;
  972. height: 60vh;
  973. .qiyong {
  974. margin-top: 0px;
  975. }
  976. .el-row {
  977. margin: 10px 0;
  978. }
  979. .required {
  980. color: #606266 !important;
  981. &::before {
  982. content: '*';
  983. margin: 0 4px 0 -7.5px;
  984. color: #f56c6c;
  985. }
  986. }
  987. .eltag {
  988. margin-top: 6px;
  989. }
  990. }
  991. .el-row {
  992. margin: 0 !important;
  993. }
  994. .question-icon {
  995. margin-left: 2px;
  996. }
  997. }
  998. .dialog-footer {
  999. display: flex;
  1000. justify-content: center;
  1001. }
  1002. ::v-deep {
  1003. .el-form-item__label {
  1004. text-align: left;
  1005. }
  1006. }
  1007. </style>