defaultSettingDialog.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. <template>
  2. <el-dialog
  3. title="配置默认数据"
  4. :visible.sync="dialogVisible"
  5. width="65%"
  6. style="margin-top:5vh"
  7. top
  8. append-to-body
  9. class="dialog"
  10. :close-on-click-modal="false"
  11. :close-on-press-escape="false"
  12. :show-close="false"
  13. >
  14. <div class="contain">
  15. <div class="form">
  16. <el-form ref="subformRef" :model="form" label-width="100px">
  17. <el-row :gutter="20">
  18. <el-col :span="12">
  19. <el-form-item label="默认部门:">
  20. <ibps-user-selector
  21. v-model="form.bian_zhi_bu_men_"
  22. size="mini"
  23. type="position"
  24. readonly-text="text"
  25. :disabled="false"
  26. :multiple="false"
  27. style="width:100%"
  28. :filter="filter"
  29. filtrate
  30. />
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="12">
  34. <el-form-item label="默认岗位:">
  35. <el-select v-model="form.gang_wei_" placeholder="请选择" size="mini" style="width:100%">
  36. <el-option
  37. v-for="item in monitoringpPosition"
  38. :key="item.id_"
  39. :label="item.wei_hu_gang_wei_"
  40. :value="item.wei_hu_gang_wei_"
  41. />
  42. </el-select>
  43. </el-form-item>
  44. </el-col>
  45. </el-row>
  46. <el-row :gutter="20">
  47. <el-col :span="12">
  48. <el-form-item label="默认周期:">
  49. <el-select v-model="form.zhou_qi_" placeholder="请选择" size="mini" style="width:100%">
  50. <el-option
  51. v-for="item in period"
  52. :key="item.value"
  53. :label="item.label"
  54. :value="item.value"
  55. />
  56. </el-select>
  57. </el-form-item>
  58. </el-col>
  59. </el-row>
  60. <el-row v-if="form.zhou_qi_!==''" :gutter="20">
  61. <el-col :span="12">
  62. <el-form-item :label="labelShow">
  63. <el-checkbox-group v-if="form.zhou_qi_==='每日'" v-model="dayCheck" style="width:100%">
  64. <el-checkbox v-for="item in weekDays" :key="item.value" :label="item.value" size="mini">{{ item.label }}</el-checkbox>
  65. </el-checkbox-group>
  66. <template v-if="form.zhou_qi_==='每周'">
  67. <div class="radio" style="width:100%">
  68. <el-radio v-for="item in weekDays" :key="item.value" v-model="weekCheck" :label="item.value" size="mini">{{ item.label }}</el-radio>
  69. </div>
  70. </template>
  71. <el-select v-if="form.zhou_qi_==='每月'" v-model="monthCheck" placeholder="请选择" size="mini" style="width:100%">
  72. <el-option
  73. v-for="item in 28"
  74. :key="item"
  75. :label="`第${item}天`"
  76. :value="item"
  77. />
  78. </el-select>
  79. <el-select v-if="form.zhou_qi_==='每季度'" v-model="quarterCheck" placeholder="请选择" size="mini" style="width:100%">
  80. <el-option
  81. v-for="item in 3"
  82. :key="item"
  83. :label="`第${item}个月`"
  84. :value="item"
  85. />
  86. </el-select>
  87. <el-select v-if="form.zhou_qi_==='每半年'" v-model="halfYearCheck" placeholder="请选择" size="mini" style="width:100%">
  88. <el-option
  89. v-for="item in 6"
  90. :key="item"
  91. :label="`第${item}个月`"
  92. :value="item"
  93. />
  94. </el-select>
  95. <el-select v-if="form.zhou_qi_==='每年'" v-model="yearCheck" placeholder="请选择" size="mini" style="width:100%">
  96. <el-option
  97. v-for="item in 12"
  98. :key="item"
  99. :label="`第${item}个月`"
  100. :value="item"
  101. />
  102. </el-select>
  103. <el-select v-if="form.zhou_qi_==='间隔'" v-model="sepCheck" placeholder="请选择" size="mini" style="width:100%">
  104. <el-option
  105. v-for="item in 30"
  106. :key="item"
  107. :label="`每隔${item}天`"
  108. :value="item"
  109. />
  110. </el-select>
  111. </el-form-item>
  112. </el-col>
  113. <el-col v-if="nextDate" :span="12">
  114. <el-form-item label="下次监测日期为:" label-width="150">
  115. <el-tag size="mini" class="eltag">{{ nextDate }}</el-tag>
  116. </el-form-item>
  117. </el-col>
  118. <el-col v-if="form.zhou_qi_==='间隔'" :span="12">
  119. <el-form-item label="开始监测时间:" prop="">
  120. <el-date-picker
  121. v-model="form.kai_shi_shi_jian_"
  122. :clearable="false"
  123. type="date"
  124. placeholder="选择监测开始时间"
  125. :picker-options="pickerOptions"
  126. value-format="yyyy-MM-dd"
  127. size="mini"
  128. style="width:100%"
  129. />
  130. </el-form-item>
  131. </el-col>
  132. </el-row>
  133. <el-row :gutter="20">
  134. <el-col :span="12">
  135. <el-form-item label="默认控制条件:">
  136. <el-input v-model="form.tiao_jian_" type="textarea" :rows="2" size="mini" style="width:100%" />
  137. </el-form-item>
  138. </el-col>
  139. <el-col :span="12">
  140. <el-form-item label="默认控制标准:">
  141. <el-input v-model="form.kong_zhi_biao_zhu" type="textarea" :rows="2" size="mini" style="width:100%" />
  142. </el-form-item>
  143. </el-col>
  144. </el-row>
  145. <el-row :gutter="20">
  146. <el-col :span="24">
  147. <FacilityData v-if="form.lie_biao_shu_ju_" :form-data="{lieBiaoShuJu:form.lie_biao_shu_ju_}" :is-cul="false" @change-data="onFacilityData" />
  148. </el-col>
  149. </el-row>
  150. </el-form>
  151. </div>
  152. </div>
  153. <span slot="footer" class="dialog-footer">
  154. <el-button size="mini" type="info" icon="el-icon-setting" @click="emitParent('settingEmpty')">为空替换</el-button>
  155. <el-button size="mini" type="info" icon="el-icon-setting" @click="emitParent('settingAll')">全部替换</el-button>
  156. <el-button size="mini" type="danger" icon="ibps-icon-close" @click="handleClose">取消</el-button>
  157. </span>
  158. </el-dialog>
  159. </template>
  160. <script>
  161. import ibpsUserSelector from '@/business/platform/org/selector'
  162. import FacilityData from '@/views/component/facility/facilityData.vue'
  163. export default {
  164. components: {
  165. FacilityData, ibpsUserSelector
  166. },
  167. props: {
  168. dialogVisible: {
  169. type: Boolean,
  170. default: false
  171. },
  172. params: {
  173. type: Object,
  174. default: () => ({})
  175. },
  176. jianCeGangWeiList: {
  177. type: Array,
  178. default: () => []
  179. },
  180. day: {
  181. type: Array,
  182. default: () => []
  183. },
  184. week: {
  185. type: [String, Number],
  186. default: ''
  187. },
  188. month: {
  189. type: [String, Number],
  190. default: ''
  191. },
  192. quarter: {
  193. type: [String, Number],
  194. default: ''
  195. },
  196. halfYear: {
  197. type: [String, Number],
  198. default: ''
  199. },
  200. year: {
  201. type: [String, Number],
  202. default: ''
  203. },
  204. sep: {
  205. type: [String, Number],
  206. default: ''
  207. }
  208. },
  209. data () {
  210. return {
  211. pickerOptions: {
  212. disabledDate (time) {
  213. return time.getTime() < (Date.now() - (24 * 60 * 1000 * 60))
  214. }
  215. },
  216. dayCheck: [],
  217. weekCheck: '',
  218. monthCheck: '',
  219. quarterCheck: '',
  220. halfYearCheck: '',
  221. yearCheck: '',
  222. sepCheck: '',
  223. weekDays: [{ label: '周一', value: 1 }, { label: '周二', value: 2 }, { label: '周三', value: 3 }, { label: '周四', value: 4 }, { label: '周五', value: 5 }, { label: '周六', value: 6 }, { label: '周日', value: 7 }],
  224. nextDate: '',
  225. form: {},
  226. filter: [{
  227. descVal: '1',
  228. includeSub: true,
  229. old: 'position',
  230. partyId: this.$store.getters.userInfo.employee.positions,
  231. partyName: '',
  232. scriptContent: '',
  233. type: 'user',
  234. userType: 'position'
  235. }],
  236. period: [
  237. { label: '日监测', value: '每日' },
  238. { label: '周监测', value: '每周' },
  239. { label: '月监测', value: '每月' },
  240. { label: '季度监测', value: '每季度' },
  241. { label: '半年监测', value: '每半年' },
  242. { label: '年监测', value: '每年' },
  243. { label: '按时间间隔监测', value: '间隔' }
  244. ]
  245. }
  246. },
  247. computed: {
  248. monitoringpPosition () {
  249. return this.jianCeGangWeiList.filter(i => i.suo_shu_bu_men_ === this.form.bian_zhi_bu_men_)
  250. },
  251. labelShow () {
  252. if (this.form.zhou_qi_) {
  253. if (this.form.zhou_qi_ !== '间隔') {
  254. return this.form.zhou_qi_.split('每')[1] + '监测日期:'
  255. }
  256. return '间隔时间:'
  257. }
  258. return ''
  259. }
  260. },
  261. watch: {
  262. params: {
  263. handler (val) {
  264. this.form = val
  265. },
  266. immediate: true
  267. },
  268. day: {
  269. handler (val) {
  270. this.dayCheck = val
  271. }
  272. },
  273. week: {
  274. handler (val) {
  275. this.weekCheck = val
  276. }
  277. },
  278. month: {
  279. handler (val) {
  280. this.monthCheck = val
  281. }
  282. },
  283. quarter: {
  284. handler (val) {
  285. this.quarterCheck = val
  286. }
  287. },
  288. halfYear: {
  289. handler (val) {
  290. this.halfYearCheck = val
  291. }
  292. },
  293. year: {
  294. handler (val) {
  295. this.yearCheck = val
  296. }
  297. },
  298. sep: {
  299. handler (val) {
  300. this.sepCheck = val
  301. }
  302. },
  303. 'form.zhou_qi_' (val, old) {
  304. if (!old) return
  305. this.dayCheck = []
  306. this.weekCheck = ''
  307. this.monthCheck = ''
  308. this.quarterCheck = ''
  309. this.halfYearCheck = ''
  310. this.yearCheck = ''
  311. this.sepCheck = ''
  312. this.form.kai_shi_shi_jian_ = ''
  313. this.nextDate = ''
  314. },
  315. dayCheck: {
  316. handler: function (val, oldVal) {
  317. this.formatRiQi()
  318. if (val.length === 0) {
  319. this.nextDate = ''
  320. return
  321. }
  322. const temp_val = JSON.parse(JSON.stringify(val))
  323. const today = new Date()
  324. temp_val.sort(function (a, b) {
  325. return a - b
  326. })
  327. const num = temp_val.findIndex(e => e > today.getDay())
  328. if (temp_val.length > 0 && num !== -1) {
  329. this.nextDate = this.getDayDate(temp_val[num], 0)
  330. } else if (temp_val.length > 0 && num === -1) {
  331. this.nextDate = this.getDayDate(temp_val[0], 1)
  332. } else {
  333. this.nextDate = ''
  334. }
  335. },
  336. immediate: true
  337. },
  338. weekCheck: {
  339. handler: function (val, oldVal) {
  340. this.formatRiQi()
  341. if (val === '') {
  342. this.nextDate = ''
  343. return
  344. }
  345. const today = new Date()
  346. const weekNum = []
  347. weekNum.push(val)
  348. const num = weekNum.findIndex(e => e > today.getDay())
  349. if (val !== '' && num !== -1) {
  350. this.nextDate = this.getDayDate(weekNum[0], 0)
  351. } else if (val !== '' && num === -1) {
  352. this.nextDate = this.getDayDate(weekNum[0], 1)
  353. } else {
  354. this.nextDate = ''
  355. }
  356. },
  357. immediate: true
  358. },
  359. monthCheck: {
  360. handler: function (val, oldVal) {
  361. this.formatRiQi()
  362. if (val === '') {
  363. this.nextDate = ''
  364. return
  365. }
  366. const today = new Date()
  367. const day = today.getDate()
  368. const nextMonth = this.getNextMonthDate(today, val, 1)
  369. const currentMonth = this.getNextMonthDate(today, val, 0)
  370. this.nextDate = val > day ? currentMonth : nextMonth
  371. }
  372. // immediate: true
  373. },
  374. quarterCheck: {
  375. handler: function (val, oldVal) {
  376. this.formatRiQi()
  377. if (val === '') {
  378. this.nextDate = ''
  379. return
  380. }
  381. const quarterList = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
  382. const today = new Date()
  383. const month = today.getMonth() + 1
  384. const qu = this.getQuarter(today)
  385. const nowM = quarterList[qu - 1][val - 1]
  386. const nextM = quarterList[qu % 4][val - 1]
  387. const endMonth = month >= nowM ? nextM : nowM
  388. const yearPJ = today.getFullYear()
  389. const monthPJ = endMonth > 9 ? endMonth : '0' + endMonth
  390. this.nextDate = yearPJ + '-' + monthPJ + '-01'
  391. }
  392. // immediate: true
  393. },
  394. halfYearCheck: {
  395. handler: function (val, oldVal) {
  396. this.formatRiQi()
  397. if (val === '') {
  398. this.nextDate = ''
  399. return
  400. }
  401. const midList = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]]
  402. const today = new Date()
  403. const month = today.getMonth() + 1
  404. const qu = month > 6 ? 2 : 1
  405. const nowM = midList[qu - 1][val - 1]
  406. const nextM = midList[qu % 2][val - 1]
  407. const endMonth = month >= nowM ? nextM : nowM
  408. const yearPJ = month >= nowM ? today.getFullYear() + 1 : today.getFullYear()
  409. const monthPJ = endMonth > 9 ? endMonth : '0' + endMonth
  410. this.nextDate = yearPJ + '-' + monthPJ + '-01'
  411. }
  412. // immediate: true
  413. },
  414. yearCheck: {
  415. handler: function (val, oldVal) {
  416. this.formatRiQi()
  417. if (val === '') {
  418. this.nextDate = ''
  419. return
  420. }
  421. const today = new Date()
  422. const month = today.getMonth() + 1
  423. const year = today.getFullYear()
  424. const qu = month >= val ? year + 1 : year
  425. const monthPJ = val > 9 ? val : '0' + val
  426. this.nextDate = qu + '-' + monthPJ + '-01'
  427. }
  428. // immediate: true
  429. },
  430. sepCheck: {
  431. handler: function (val, oldVal) {
  432. this.formatRiQi()
  433. }
  434. },
  435. 'form.kai_shi_shi_jian_': {
  436. handler: function (val, oldVal) {
  437. this.formatRiQi()
  438. }
  439. }
  440. },
  441. methods: {
  442. getDayDate (type, dates) {
  443. const now = new Date()
  444. const nowTime = now.getTime()
  445. const day = now.getDay()
  446. const longTime = 24 * 60 * 60 * 1000
  447. const n = longTime * 7 * (dates || 0)
  448. let dd = nowTime - (day - type) * longTime + n
  449. dd = new Date(dd)
  450. const y = dd.getFullYear()
  451. let m = dd.getMonth() + 1
  452. let d = dd.getDate()
  453. m = m < 10 ? '0' + m : m
  454. d = d < 10 ? '0' + d : d
  455. const daynow = y + '-' + m + '-' + d
  456. return daynow
  457. },
  458. // 获取往后几个月相应的日期
  459. // currentDate:当前日期
  460. // dayOfMonth:获取几号
  461. // val:往后几个月
  462. getNextMonthDate (currentDate, dayOfMonth, val) {
  463. const currentYear = currentDate.getFullYear()
  464. const currentMonth = currentDate.getMonth()
  465. const nextMonth = currentMonth + val
  466. const nextMonthDate = new Date(currentYear, nextMonth, dayOfMonth)
  467. const formattedDate = nextMonthDate.toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')
  468. return formattedDate
  469. },
  470. // 获取当前季度
  471. getQuarter (date) {
  472. return Math.floor(date.getMonth() / 3) + 1
  473. },
  474. formatRiQi () {
  475. switch (this.form.zhou_qi_) {
  476. case '每日':
  477. if (!this.dayCheck || this.dayCheck.length === 0) {
  478. this.form.jian_ce_ri_qi_ = ''
  479. this.form.ri_qi_lie_biao_ = ''
  480. } else if (this.dayCheck.length === 7) {
  481. this.form.jian_ce_ri_qi_ = '每天'
  482. this.form.ri_qi_lie_biao_ = '1,2,3,4,5,6,7'
  483. } else {
  484. const temp_dayCheck = JSON.parse(JSON.stringify(this.dayCheck))
  485. temp_dayCheck.sort(function (a, b) {
  486. return a - b
  487. })
  488. this.form.ri_qi_lie_biao_ = temp_dayCheck.join(',')
  489. this.form.jian_ce_ri_qi_ = '每周' + temp_dayCheck.join(',')
  490. }
  491. break
  492. case '每周':
  493. if (this.weekCheck) {
  494. this.form.jian_ce_ri_qi_ = '每周' + this.weekCheck
  495. this.form.ri_qi_lie_biao_ = this.weekCheck + ''
  496. } else {
  497. this.form.jian_ce_ri_qi_ = ''
  498. this.form.ri_qi_lie_biao_ = ''
  499. }
  500. break
  501. case '每月':
  502. if (this.monthCheck) {
  503. this.form.jian_ce_ri_qi_ = '每个月第' + this.monthCheck + '天'
  504. this.form.ri_qi_lie_biao_ = this.monthCheck + ''
  505. } else {
  506. this.form.jian_ce_ri_qi_ = ''
  507. this.form.ri_qi_lie_biao_ = ''
  508. }
  509. break
  510. case '每季度':
  511. if (this.quarterCheck) {
  512. this.form.jian_ce_ri_qi_ = '每季度第' + this.quarterCheck + '个月'
  513. this.form.ri_qi_lie_biao_ = this.quarterCheck + ''
  514. } else {
  515. this.form.jian_ce_ri_qi_ = ''
  516. this.form.ri_qi_lie_biao_ = ''
  517. }
  518. break
  519. case '每半年':
  520. if (this.halfYearCheck) {
  521. this.form.jian_ce_ri_qi_ = '每半年第' + this.halfYearCheck + '个月'
  522. this.form.ri_qi_lie_biao_ = this.halfYearCheck + ''
  523. } else {
  524. this.form.jian_ce_ri_qi_ = ''
  525. this.form.ri_qi_lie_biao_ = ''
  526. }
  527. break
  528. case '每年':
  529. if (this.yearCheck) {
  530. this.form.jian_ce_ri_qi_ = '每年第' + this.yearCheck + '个月'
  531. this.form.ri_qi_lie_biao_ = this.yearCheck + ''
  532. } else {
  533. this.form.jian_ce_ri_qi_ = ''
  534. this.form.ri_qi_lie_biao_ = ''
  535. }
  536. break
  537. case '间隔':
  538. if (this.sepCheck && this.form.kai_shi_shi_jian_) {
  539. this.form.jian_ce_ri_qi_ = this.form.kai_shi_shi_jian_ + '起每隔' + this.sepCheck + '天'
  540. this.form.ri_qi_lie_biao_ = this.sepCheck + ''
  541. } else {
  542. this.form.jian_ce_ri_qi_ = ''
  543. this.form.ri_qi_lie_biao_ = ''
  544. }
  545. break
  546. default:
  547. this.form.jian_ce_ri_qi_ = ''
  548. this.form.ri_qi_lie_biao_ = ''
  549. break
  550. }
  551. },
  552. emitParent (type) {
  553. let msg = ''
  554. if (type === 'settingEmpty') msg = '该操作会将未设置过的配置子表数据设置为默认值,是否继续?'
  555. if (type === 'settingAll') msg = '该操作会将所有配置子表数据替换为默认值,是否继续?'
  556. this.$confirm(msg, '提示', {
  557. confirmButtonText: '继续',
  558. cancelButtonText: '取消',
  559. type: 'warning'
  560. }).then(() => {
  561. this.$emit('emitParent', type)
  562. }).catch(() => {
  563. })
  564. },
  565. // 接收自定义组件数据
  566. onFacilityData (...arg) {
  567. if (arg.length > 1) {
  568. this.form.lie_biao_shu_ju_ = arg[1]
  569. }
  570. },
  571. handleClose () {
  572. this.$emit('update:dialogVisible', false)
  573. }
  574. }
  575. }
  576. </script>
  577. <style lang="scss" scoped>
  578. .contain{
  579. .form{
  580. padding: 20px;
  581. height: 60vh;
  582. .el-row{
  583. margin: 10px 0;
  584. }
  585. }
  586. .el-row{
  587. margin: 0 !important;
  588. }
  589. .eltag{
  590. margin-top: 6px;
  591. }
  592. }
  593. .dialog-footer{
  594. display: flex;
  595. justify-content: center;
  596. }
  597. ::v-deep {
  598. .el-form-item__label{
  599. text-align: left
  600. }
  601. .el-form-item__content{
  602. display: flex;
  603. }
  604. }
  605. </style>