fecDialog.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  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 v-model="form.jian_ce_gang_wei_" placeholder="请选择" size="mini" style="width:80%">
  42. <el-option
  43. v-for="item in monitoringpPosition"
  44. :key="item.id_"
  45. :label="item.wei_hu_gang_wei_"
  46. :value="item.wei_hu_gang_wei_"
  47. />
  48. </el-select>
  49. </el-form-item>
  50. </el-col>
  51. </el-row>
  52. <el-row>
  53. <el-col :span="12">
  54. <el-form-item v-if="shouldRequired('fang_jian_')" label="房间:">
  55. <template slot="label">
  56. <span class="required">房间:</span>
  57. </template>
  58. <ibps-link-data
  59. v-model="form.fang_jian_"
  60. style="width:80%"
  61. size="mini"
  62. template-key="fjzly"
  63. :multiple="false"
  64. :temp-search="true"
  65. label-key="fang_jian_ming_ha"
  66. value-key="fang_jian_ming_ha"
  67. :allow-create="false"
  68. :filterable="false"
  69. @change-link-data="fangJianChange"
  70. />
  71. </el-form-item>
  72. <el-form-item v-else label="房间:">
  73. <ibps-link-data
  74. v-model="form.fang_jian_"
  75. style="width:80%"
  76. size="mini"
  77. template-key="fjzly"
  78. :multiple="false"
  79. :temp-search="true"
  80. label-key="fang_jian_ming_ha"
  81. value-key="fang_jian_ming_ha"
  82. :allow-create="false"
  83. :filterable="false"
  84. @change-link-data="fangJianChange"
  85. />
  86. </el-form-item>
  87. </el-col>
  88. <el-col v-show="form.qu_yu_" :span="12">
  89. <el-form-item label="区域:">
  90. <template slot="label">
  91. <span>区域</span>
  92. <el-tooltip effect="dark" content="区域由房间自动带出" placement="top">
  93. <i class="el-icon-question question-icon">:</i>
  94. </el-tooltip>
  95. </template>
  96. <span>{{ form.qu_yu_ }}</span>
  97. </el-form-item>
  98. </el-col>
  99. </el-row>
  100. <!-- v-if="isShowJkDevice" -->
  101. <el-row>
  102. <el-col :span="12">
  103. <el-form-item label="监控设备:">
  104. <ibps-link-data
  105. v-model="form.deviceno2_"
  106. style="width:80%"
  107. size="mini"
  108. template-key="jksbxz"
  109. :multiple="false"
  110. :temp-search="true"
  111. label-key="deviceInfo"
  112. value-key="deviceInfo"
  113. :allow-create="false"
  114. :filterable="false"
  115. @change-link-data="deviceno2Change"
  116. />
  117. </el-form-item>
  118. </el-col>
  119. </el-row>
  120. <el-row v-if="isShowDevice">
  121. <el-col :span="12">
  122. <el-form-item v-if="deviceIsRequired" label="被控设备/设施编号:" label-width="140">
  123. <template slot="label">
  124. <span class="required">被控设备/设施编号:</span>
  125. </template>
  126. <ibps-custom-dialog
  127. v-model="form.deviceno1_"
  128. size="mini"
  129. template-key="sbxzmcgl"
  130. :multiple="false"
  131. :disabled="false"
  132. type="dialog"
  133. class="custom-dialog"
  134. placeholder="请选择设备"
  135. icon="el-icon-search"
  136. style="width:80%"
  137. @change-link-data="deviceno1Change"
  138. />
  139. </el-form-item>
  140. <el-form-item v-else label="被控设备/设施编号:" label-width="140">
  141. <ibps-link-data
  142. v-model="form.deviceno1_"
  143. style="width:80%"
  144. size="mini"
  145. template-key="sbxzsshj"
  146. :multiple="false"
  147. :temp-search="true"
  148. label-key="yuan_she_bei_bian"
  149. value-key="yuan_she_bei_bian"
  150. :allow-create="false"
  151. :filterable="false"
  152. @change-link-data="deviceno1Change"
  153. />
  154. </el-form-item>
  155. </el-col>
  156. <el-col v-show="form.deviceno1_" :span="12">
  157. <el-form-item v-if="deviceIsRequired" label="被控设备/设施名称:" label-width="140">
  158. <template slot="label">
  159. <span>被控设备/设施名称</span>
  160. <el-tooltip effect="dark" content="选择设备后自动带出名称" placement="top">
  161. <i class="el-icon-question question-icon">:</i>
  162. </el-tooltip>
  163. </template>
  164. <div>{{ form.devicename1_ }}</div>
  165. </el-form-item>
  166. <el-form-item v-else label="被控设备/设施名称:" label-width="140">
  167. <el-input v-model="form.devicename1_" size="mini" style="width:80%" />
  168. </el-form-item>
  169. </el-col>
  170. </el-row>
  171. <el-row>
  172. <el-col :span="12">
  173. <el-form-item label="监测周期:">
  174. <template slot="label">
  175. <span class="required">监测周期:</span>
  176. </template>
  177. <el-select v-model="form.jian_ce_zhou_qi_" placeholder="请选择" size="mini" style="width:80%">
  178. <el-option
  179. v-for="item in period"
  180. :key="item.value"
  181. :label="item.label"
  182. :value="item.value"
  183. />
  184. </el-select>
  185. </el-form-item>
  186. </el-col>
  187. <el-col :span="12">
  188. <el-form-item label="是否启用:">
  189. <template slot="label">
  190. <span>是否启用</span>
  191. <el-tooltip effect="dark" content="若该值为停用时,将不会按监测周期产生对应记录。" placement="top">
  192. <i class="el-icon-question question-icon">:</i>
  193. </el-tooltip>
  194. </template>
  195. <div class="qiyong">
  196. <el-radio v-model="form.shi_fou_qi_yong_" label="1">启用</el-radio>
  197. <el-radio v-model="form.shi_fou_qi_yong_" label="0">停用</el-radio>
  198. </div>
  199. </el-form-item>
  200. </el-col>
  201. </el-row>
  202. <el-row v-if="form.jian_ce_zhou_qi_!==''">
  203. <el-col :span="12">
  204. <el-form-item :label="labelShow">
  205. <template slot="label">
  206. <span class="required">{{ labelShow }}</span>
  207. </template>
  208. <el-checkbox-group v-if="form.jian_ce_zhou_qi_==='每日'" v-model="dayCheck" size="mini">
  209. <el-checkbox v-for="item in weekDays" :key="item.value" :label="item.value" size="mini">{{ item.label }}</el-checkbox>
  210. </el-checkbox-group>
  211. <template v-if="form.jian_ce_zhou_qi_==='每周'">
  212. <div class="radio" style="width:100%">
  213. <el-radio v-for="item in weekDays" :key="item.value" v-model="weekCheck" :label="item.value" size="mini">{{ item.label }}</el-radio>
  214. </div>
  215. </template>
  216. <el-select v-if="form.jian_ce_zhou_qi_==='每月'" v-model="monthCheck" placeholder="请选择" size="mini" style="width:80%">
  217. <el-option
  218. v-for="item in 28"
  219. :key="item"
  220. :label="`第${item}天`"
  221. :value="item"
  222. />
  223. </el-select>
  224. <el-select v-if="form.jian_ce_zhou_qi_==='每季度'" v-model="quarterCheck" placeholder="请选择" size="mini" style="width:80%">
  225. <el-option
  226. v-for="item in 3"
  227. :key="item"
  228. :label="`第${item}个月`"
  229. :value="item"
  230. />
  231. </el-select>
  232. <el-select v-if="form.jian_ce_zhou_qi_==='每半年'" v-model="halfYearCheck" placeholder="请选择" size="mini" style="width:80%">
  233. <el-option
  234. v-for="item in 6"
  235. :key="item"
  236. :label="`第${item}个月`"
  237. :value="item"
  238. />
  239. </el-select>
  240. <el-select v-if="form.jian_ce_zhou_qi_==='每年'" v-model="yearCheck" placeholder="请选择" size="mini" style="width:80%">
  241. <el-option
  242. v-for="item in 12"
  243. :key="item"
  244. :label="`第${item}个月`"
  245. :value="item"
  246. />
  247. </el-select>
  248. <el-select v-if="form.jian_ce_zhou_qi_==='间隔'" v-model="sepCheck" placeholder="请选择" size="mini" style="width:80%">
  249. <el-option
  250. v-for="item in 30"
  251. :key="item"
  252. :label="`每隔${item}天`"
  253. :value="item"
  254. />
  255. </el-select>
  256. </el-form-item>
  257. </el-col>
  258. <el-col v-if="nextDate" :span="12">
  259. <el-form-item label="下次监测日期为:">
  260. <el-tag size="mini" class="eltag">{{ nextDate }}</el-tag>
  261. </el-form-item>
  262. </el-col>
  263. <el-col v-if="form.jian_ce_zhou_qi_==='间隔'" :span="12">
  264. <el-form-item label="开始监测时间:" prop="">
  265. <el-date-picker
  266. v-model="form.kai_shi_shi_jian_"
  267. :clearable="false"
  268. type="date"
  269. placeholder="选择监测开始时间"
  270. :picker-options="pickerOptions"
  271. value-format="yyyy-MM-dd"
  272. size="mini"
  273. style="width:80%"
  274. />
  275. </el-form-item>
  276. </el-col>
  277. </el-row>
  278. <el-row>
  279. <el-col :span="12">
  280. <el-form-item label="控制条件:">
  281. <el-input v-model="form.kong_zhi_tiao_jia" type="textarea" :rows="2" size="mini" style="width:80%" />
  282. </el-form-item>
  283. </el-col>
  284. <el-col :span="12">
  285. <el-form-item label="控制标准:">
  286. <el-input v-model="form.kong_zhi_biao_zhu" type="textarea" :rows="2" size="mini" style="width:80%" />
  287. </el-form-item>
  288. </el-col>
  289. </el-row>
  290. <el-row>
  291. <el-col :span="24">
  292. <FacilityData v-if="form.lie_biao_shu_ju_" :is-cul="false" :form-data="{lieBiaoShuJu:form.lie_biao_shu_ju_}" @change-data="onFacilityData" />
  293. </el-col>
  294. </el-row>
  295. </el-form>
  296. </div>
  297. </div>
  298. <span slot="footer" class="dialog-footer">
  299. <el-button type="primary" icon="ibps-icon-save" size="mini" @click="submit">确 定</el-button>
  300. <el-button icon="ibps-icon-close" type="danger" size="mini" @click="close">取 消</el-button>
  301. </span>
  302. </el-dialog>
  303. </template>
  304. <script>
  305. import ibpsUserSelector from '@/business/platform/org/selector'
  306. import IbpsLinkData from '@/business/platform/data/templaterender/link-data'
  307. import FacilityData from '@/views/component/facility/facilityData.vue'
  308. export default {
  309. components: {
  310. FacilityData,
  311. ibpsUserSelector,
  312. IbpsLinkData,
  313. IbpsCustomDialog: () => import('@/business/platform/data/templaterender/custom-dialog')
  314. },
  315. data () {
  316. return {
  317. pickerOptions: {
  318. disabledDate (time) {
  319. return time.getTime() < (Date.now() - (24 * 60 * 1000 * 60))
  320. }
  321. },
  322. weekDays: [{ label: '周一', value: 1 }, { label: '周二', value: 2 }, { label: '周三', value: 3 }, { label: '周四', value: 4 }, { label: '周五', value: 5 }, { label: '周六', value: 6 }, { label: '周日', value: 7 }],
  323. filter: [{
  324. descVal: '1',
  325. includeSub: true,
  326. old: 'position',
  327. partyId: this.$store.getters.userInfo.employee.positions,
  328. partyName: '',
  329. scriptContent: '',
  330. type: 'user',
  331. userType: 'position'
  332. }],
  333. dialogVisible: true,
  334. title: '配置详情',
  335. jianCeGangWeiList: [],
  336. lei_xing_: '',
  337. form: {
  338. qu_yu_: '',
  339. fang_jian_: '',
  340. fang_jian_id_: '',
  341. bu_men_: '',
  342. deviceno1_: '',
  343. deviceid1_: '', // 设备id
  344. devicename1_: '',
  345. deviceno2_: '', // 监控设备
  346. deviceid2_: '', // 监控设备id
  347. jian_ce_zhou_qi_: '',
  348. jian_ce_gang_wei_: '',
  349. shi_fou_qi_yong_: '1',
  350. kong_zhi_tiao_jia: '',
  351. kong_zhi_biao_zhu: '',
  352. jian_ce_ri_qi_: '',
  353. ri_qi_lie_biao_: '',
  354. zi_wai_deng_wai_j: '', // 紫外灯外键
  355. lie_biao_shu_ju_: '',
  356. kai_shi_shi_jian_: ''
  357. },
  358. isEdit: false,
  359. nextDate: '',
  360. dayCheck: [],
  361. weekCheck: '',
  362. monthCheck: '',
  363. quarterCheck: '',
  364. halfYearCheck: '',
  365. yearCheck: '',
  366. sepCheck: '',
  367. period: [
  368. { label: '日监测', value: '每日' },
  369. { label: '周监测', value: '每周' },
  370. { label: '月监测', value: '每月' },
  371. { label: '季度监测', value: '每季度' },
  372. { label: '半年监测', value: '每半年' },
  373. { label: '年监测', value: '每年' },
  374. { label: '按时间间隔监测', value: '间隔' }
  375. ]
  376. }
  377. },
  378. computed: {
  379. monitoringpPosition () {
  380. return this.jianCeGangWeiList.filter(i => i.suo_shu_bu_men_ === this.form.bu_men_)
  381. },
  382. isShowJkDevice () {
  383. return this.lei_xing_ !== '17-医疗废弃物交接'
  384. },
  385. isShowDevice () {
  386. return this.lei_xing_ !== '01-室内温湿度监控' && this.lei_xing_ !== '06-每日安全检查' && this.lei_xing_ !== '08-含氯有效性监测' && this.lei_xing_ !== '15-日常防护消毒' && this.lei_xing_ !== '17-医疗废弃物交接'
  387. },
  388. deviceIsRequired () {
  389. return this.lei_xing_ === '02-冰箱温度监控' || this.lei_xing_ === '05-纯水机水质监测' || this.lei_xing_ === '03-温浴箱温度监控' || this.lei_xing_ === '04-阴凉柜温度监控' || this.lei_xing_ === '16-设备排出废液'
  390. },
  391. labelShow () {
  392. if (this.form.jian_ce_zhou_qi_) {
  393. if (this.form.jian_ce_zhou_qi_ !== '间隔') {
  394. return this.form.jian_ce_zhou_qi_.split('每')[1] + '监测日期:'
  395. }
  396. return '间隔时间:'
  397. }
  398. return ''
  399. }
  400. },
  401. watch: {
  402. 'form.jian_ce_zhou_qi_' (val, old) {
  403. if (!old) return
  404. this.dayCheck = []
  405. this.weekCheck = ''
  406. this.monthCheck = ''
  407. this.quarterCheck = ''
  408. this.halfYearCheck = ''
  409. this.yearCheck = ''
  410. this.sepCheck = ''
  411. this.nextDate = ''
  412. this.form.kai_shi_shi_jian_ = ''
  413. },
  414. dayCheck: {
  415. handler: function (val, oldVal) {
  416. if (val.length === 0) {
  417. this.nextDate = ''
  418. return
  419. }
  420. const temp_val = JSON.parse(JSON.stringify(val))
  421. const today = new Date()
  422. temp_val.sort(function (a, b) {
  423. return a - b
  424. })
  425. const num = temp_val.findIndex(e => e > today.getDay())
  426. if (temp_val.length > 0 && num !== -1) {
  427. this.nextDate = this.getDayDate(temp_val[num], 0)
  428. } else if (temp_val.length > 0 && num === -1) {
  429. this.nextDate = this.getDayDate(temp_val[0], 1)
  430. } else {
  431. this.nextDate = ''
  432. }
  433. },
  434. immediate: true
  435. },
  436. weekCheck: {
  437. handler: function (val, oldVal) {
  438. if (val === '') {
  439. this.nextDate = ''
  440. return
  441. }
  442. const today = new Date()
  443. const weekNum = []
  444. weekNum.push(val)
  445. const num = weekNum.findIndex(e => e > today.getDay())
  446. if (val !== '' && num !== -1) {
  447. this.nextDate = this.getDayDate(weekNum[0], 0)
  448. } else if (val !== '' && num === -1) {
  449. this.nextDate = this.getDayDate(weekNum[0], 1)
  450. } else {
  451. this.nextDate = ''
  452. }
  453. },
  454. immediate: true
  455. },
  456. monthCheck: {
  457. handler: function (val, oldVal) {
  458. if (val === '') {
  459. this.nextDate = ''
  460. return
  461. }
  462. const today = new Date()
  463. const day = today.getDate()
  464. const nextMonth = this.getNextMonthDate(today, val, 1)
  465. const currentMonth = this.getNextMonthDate(today, val, 0)
  466. this.nextDate = val > day ? currentMonth : nextMonth
  467. }
  468. // immediate: true
  469. },
  470. quarterCheck: {
  471. handler: function (val, oldVal) {
  472. if (val === '') {
  473. this.nextDate = ''
  474. return
  475. }
  476. const quarterList = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
  477. const today = new Date()
  478. const month = today.getMonth() + 1
  479. const qu = this.getQuarter(today)
  480. const nowM = quarterList[qu - 1][val - 1]
  481. const nextM = quarterList[qu % 4][val - 1]
  482. const endMonth = month >= nowM ? nextM : nowM
  483. const yearPJ = today.getFullYear()
  484. const monthPJ = endMonth > 9 ? endMonth : '0' + endMonth
  485. this.nextDate = yearPJ + '-' + monthPJ + '-01'
  486. }
  487. // immediate: true
  488. },
  489. halfYearCheck: {
  490. handler: function (val, oldVal) {
  491. if (val === '') {
  492. this.nextDate = ''
  493. return
  494. }
  495. const midList = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]]
  496. const today = new Date()
  497. const month = today.getMonth() + 1
  498. const qu = month > 6 ? 2 : 1
  499. const nowM = midList[qu - 1][val - 1]
  500. const nextM = midList[qu % 2][val - 1]
  501. const endMonth = month >= nowM ? nextM : nowM
  502. const yearPJ = month >= nowM ? today.getFullYear() + 1 : today.getFullYear()
  503. const monthPJ = endMonth > 9 ? endMonth : '0' + endMonth
  504. this.nextDate = yearPJ + '-' + monthPJ + '-01'
  505. }
  506. // immediate: true
  507. },
  508. yearCheck: {
  509. handler: function (val, oldVal) {
  510. if (val === '') {
  511. this.nextDate = ''
  512. return
  513. }
  514. const today = new Date()
  515. const month = today.getMonth() + 1
  516. const year = today.getFullYear()
  517. const qu = month >= val ? year + 1 : year
  518. const monthPJ = val > 9 ? val : '0' + val
  519. this.nextDate = qu + '-' + monthPJ + '-01'
  520. }
  521. // immediate: true
  522. }
  523. },
  524. methods: {
  525. deviceno1Change (key, data) {
  526. this.form.deviceid1_ = data.id_ || ''
  527. this.form.devicename1_ = data.she_bei_ming_cheng_ || ''
  528. },
  529. deviceno2Change (key, data) {
  530. this.form.deviceid2_ = data.deviceId || ''
  531. },
  532. fangJianChange (key, data) {
  533. this.form.fang_jian_id_ = data.id_ || ''
  534. this.form.qu_yu_ = data.qu_yu_ || ''
  535. this.form.kong_zhi_biao_zhu = data.kong_zhi_biao_zhu || ''
  536. },
  537. // 接收自定义组件数据
  538. onFacilityData (...arg) {
  539. if (arg.length > 1) {
  540. this.form.lie_biao_shu_ju_ = arg[1]
  541. }
  542. },
  543. // 格式化数据
  544. formatForm () {
  545. // 监测日期格式化
  546. switch (this.form.jian_ce_zhou_qi_) {
  547. case '每日':
  548. if (!this.dayCheck || this.dayCheck.length === 0) {
  549. this.form.jian_ce_ri_qi_ = ''
  550. this.form.ri_qi_lie_biao_ = ''
  551. } else if (this.dayCheck.length === 7) {
  552. this.form.jian_ce_ri_qi_ = '每天'
  553. this.form.ri_qi_lie_biao_ = '1,2,3,4,5,6,7'
  554. } else {
  555. this.dayCheck.sort(function (a, b) {
  556. return a - b
  557. })
  558. this.form.jian_ce_ri_qi_ = '每周' + this.dayCheck.join(',')
  559. this.form.ri_qi_lie_biao_ = this.dayCheck.join(',')
  560. }
  561. break
  562. case '每周':
  563. if (this.weekCheck) {
  564. this.form.jian_ce_ri_qi_ = '每周' + this.weekCheck
  565. this.form.ri_qi_lie_biao_ = this.weekCheck + ''
  566. } else {
  567. this.form.jian_ce_ri_qi_ = ''
  568. this.form.ri_qi_lie_biao_ = ''
  569. }
  570. break
  571. case '每月':
  572. if (this.monthCheck) {
  573. this.form.jian_ce_ri_qi_ = '每个月第' + this.monthCheck + '天'
  574. this.form.ri_qi_lie_biao_ = this.monthCheck + ''
  575. } else {
  576. this.form.jian_ce_ri_qi_ = ''
  577. this.form.ri_qi_lie_biao_ = ''
  578. }
  579. break
  580. case '每季度':
  581. if (this.quarterCheck) {
  582. this.form.jian_ce_ri_qi_ = '每季度第' + [this.quarterCheck] + '个月'
  583. this.form.ri_qi_lie_biao_ = this.quarterCheck + ''
  584. } else {
  585. this.form.jian_ce_ri_qi_ = ''
  586. this.form.ri_qi_lie_biao_ = ''
  587. }
  588. break
  589. case '每半年':
  590. if (this.halfYearCheck) {
  591. this.form.jian_ce_ri_qi_ = '每半年第' + [this.halfYearCheck] + '个月'
  592. this.form.ri_qi_lie_biao_ = this.halfYearCheck + ''
  593. } else {
  594. this.form.jian_ce_ri_qi_ = ''
  595. this.form.ri_qi_lie_biao_ = ''
  596. }
  597. break
  598. case '每年':
  599. if (this.yearCheck) {
  600. this.form.jian_ce_ri_qi_ = '每年第' + [this.yearCheck] + '个月'
  601. this.form.ri_qi_lie_biao_ = this.yearCheck + ''
  602. } else {
  603. this.form.jian_ce_ri_qi_ = ''
  604. this.form.ri_qi_lie_biao_ = ''
  605. }
  606. break
  607. case '间隔':
  608. if (this.sepCheck && this.form.kai_shi_shi_jian_) {
  609. this.form.jian_ce_ri_qi_ = this.form.kai_shi_shi_jian_ + '起每隔' + this.sepCheck + '天'
  610. this.form.ri_qi_lie_biao_ = this.sepCheck + ''
  611. } else {
  612. this.form.jian_ce_ri_qi_ = ''
  613. this.form.ri_qi_lie_biao_ = ''
  614. }
  615. break
  616. default:
  617. break
  618. }
  619. },
  620. checkForm () {
  621. if (this.form.bu_men_ === '') {
  622. throw new Error('部门信息缺失!')
  623. }
  624. if (this.form.jian_ce_ri_qi_ === '') {
  625. throw new Error('监测日期信息缺失!')
  626. }
  627. if (this.form.jian_ce_gang_wei_ === '') {
  628. throw new Error('监测岗位信息缺失!')
  629. }
  630. if (this.deviceIsRequired && this.form.deviceno1_ === '') {
  631. throw new Error('请先选择设备!')
  632. }
  633. if (this.shouldRequired('fang_jian_') && this.form.fang_jian_ === '') {
  634. throw new Error('请先选择房间!')
  635. }
  636. if (this.form.lie_biao_shu_ju_) {
  637. const lie_biao_shu_ju_ = JSON.parse(this.form.lie_biao_shu_ju_)
  638. for (let i = 0; i < lie_biao_shu_ju_.length; i++) {
  639. const item = lie_biao_shu_ju_[i]
  640. if (!item.label && (item.range.length !== 2 || item.range[0] === null || item.range[1] === null) && (!item.fixValue) && (!item.unit)) {
  641. throw new Error(`第${i + 1}行数据非法!`)
  642. }
  643. }
  644. }
  645. },
  646. submit () {
  647. try {
  648. this.formatForm()
  649. this.checkForm()
  650. this.$emit('onSubmit', { form: this.form, isEdit: this.isEdit })
  651. } catch (error) {
  652. this.$message.warning(error.message)
  653. }
  654. },
  655. close () {
  656. this.$emit('onClose')
  657. },
  658. // 格式化监测日期
  659. formatData () {
  660. if (this.form.jian_ce_ri_qi_) {
  661. this.$nextTick(() => {
  662. switch (this.form.jian_ce_zhou_qi_) {
  663. case '每日':
  664. if (this.form.jian_ce_ri_qi_ === '每天') {
  665. this.dayCheck = [1, 2, 3, 4, 5, 6, 7]
  666. } else {
  667. this.dayCheck = this.form.jian_ce_ri_qi_.split('每周')[1].split(',').map(item => +item)
  668. }
  669. break
  670. case '每周':
  671. this.weekCheck = +this.form.jian_ce_ri_qi_.split('每周')[1]
  672. break
  673. case '每月':
  674. this.monthCheck = +this.form.jian_ce_ri_qi_.split('每个月第')[1].split('天')[0]
  675. break
  676. case '每季度':
  677. this.quarterCheck = +this.form.jian_ce_ri_qi_.split('每季度第')[1].split('个月')[0]
  678. break
  679. case '每半年':
  680. this.halfYearCheck = +this.form.jian_ce_ri_qi_.split('每半年第')[1].split('个月')[0]
  681. break
  682. case '每年':
  683. this.yearCheck = +this.form.jian_ce_ri_qi_.split('每年第')[1].split('个月')[0]
  684. break
  685. case '间隔':
  686. this.sepCheck = +this.form.ri_qi_lie_biao_
  687. break
  688. default:
  689. break
  690. }
  691. })
  692. }
  693. },
  694. open (row, jianCeGangWeiList, parentForm) {
  695. this.dialogVisible = true
  696. this.jianCeGangWeiList = jianCeGangWeiList
  697. this.lei_xing_ = parentForm.lei_xing_
  698. this.isEdit = !!(row && row.zi_wai_deng_wai_j)
  699. console.log('parentForm111111', jianCeGangWeiList, parentForm.bian_zhi_bu_men_)
  700. // 编辑
  701. if (this.isEdit) {
  702. // this.form = JSON.parse(JSON.stringify(row))
  703. const temp = JSON.parse(JSON.stringify(row))
  704. Object.assign(this.form, temp)
  705. } else {
  706. this.form.zi_wai_deng_wai_j = this.$utils.guid()
  707. this.form.bu_men_ = parentForm.bian_zhi_bu_men_
  708. this.form.jian_ce_gang_wei_ = parentForm.gang_wei_
  709. this.form.jian_ce_ri_qi_ = parentForm.jian_ce_ri_qi_
  710. this.form.kong_zhi_tiao_jia = parentForm.tiao_jian_
  711. this.form.kong_zhi_biao_zhu = parentForm.kong_zhi_biao_zhu
  712. this.form.jian_ce_zhou_qi_ = parentForm.zhou_qi_
  713. this.form.ri_qi_lie_biao_ = parentForm.ri_qi_lie_biao_
  714. this.form.lie_biao_shu_ju_ = parentForm.lie_biao_shu_ju_
  715. this.form.kai_shi_shi_jian_ = parentForm.kai_shi_shi_jian_
  716. }
  717. this.formatData()
  718. },
  719. getDayDate (type, dates) {
  720. const now = new Date()
  721. const nowTime = now.getTime()
  722. const day = now.getDay()
  723. const longTime = 24 * 60 * 60 * 1000
  724. const n = longTime * 7 * (dates || 0)
  725. let dd = nowTime - (day - type) * longTime + n
  726. dd = new Date(dd)
  727. const y = dd.getFullYear()
  728. let m = dd.getMonth() + 1
  729. let d = dd.getDate()
  730. m = m < 10 ? '0' + m : m
  731. d = d < 10 ? '0' + d : d
  732. const daynow = y + '-' + m + '-' + d
  733. return daynow
  734. },
  735. // 获取往后几个月相应的日期
  736. // currentDate:当前日期
  737. // dayOfMonth:获取几号
  738. // val:往后几个月
  739. getNextMonthDate (currentDate, dayOfMonth, val) {
  740. const currentYear = currentDate.getFullYear()
  741. const currentMonth = currentDate.getMonth()
  742. const nextMonth = currentMonth + val
  743. const nextMonthDate = new Date(currentYear, nextMonth, dayOfMonth)
  744. const formattedDate = nextMonthDate.toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')
  745. return formattedDate
  746. },
  747. // 获取当前季度
  748. getQuarter (date) {
  749. return Math.floor(date.getMonth() / 3) + 1
  750. }
  751. }
  752. }
  753. </script>
  754. <style lang="scss">
  755. .contain{
  756. .main{
  757. padding: 20px;
  758. height: 60vh;
  759. .qiyong{
  760. margin-top: 0px;
  761. }
  762. .el-row{
  763. margin: 10px 0;
  764. }
  765. .required{
  766. color: #606266 !important;
  767. &::before{
  768. content: '*';
  769. margin: 0 4px 0 -7.5px;
  770. color: #F56C6C;
  771. }
  772. }
  773. .eltag{
  774. margin-top: 6px;
  775. }
  776. }
  777. .el-row{
  778. margin: 0 !important;
  779. }
  780. .question-icon{
  781. margin-left: 2px;
  782. }
  783. }
  784. .dialog-footer{
  785. display: flex;
  786. justify-content: center;
  787. }
  788. ::v-deep {
  789. .el-form-item__label{
  790. text-align: left
  791. }
  792. }
  793. </style>