fecDialog.vue 36 KB

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