deviceSubtableDialog.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <template>
  2. <el-dialog ref="dialog" :visible.sync="dialogVisible" :close-on-click-modal="false" class="form-renderer-dialog" :width="width" :top="top" :title="dynamicParams.editFromType" :custom-class="customClass" append-to-body @close="closeDialog">
  3. <div class="maintenanceCycle">
  4. <div class="maintenanceFont">维护周期:</div>
  5. <el-select v-model="cycleValue" clearable placeholder="请选择">
  6. <el-option
  7. v-for="item in cycleOptions"
  8. :key="item.value"
  9. :label="item.label"
  10. :value="item.value"
  11. />
  12. </el-select>
  13. </div>
  14. <div v-if="judgeShow===7" class="maintenanceCycle" style="align-items: baseline;">
  15. <div class="maintenanceFont">间隔时间:</div>
  16. <el-select v-if="judgeShow==7" v-model="sepValue" clearable placeholder="请选择">
  17. <el-option
  18. v-for="item in 30"
  19. :key="item"
  20. :label="`每隔${item}天`"
  21. :value="item"
  22. />
  23. </el-select>
  24. </div>
  25. <div v-if="judgeShow===7" class="maintenanceCycle" style="align-items: baseline;">
  26. <div class="maintenanceFont">开始保养时间:</div>
  27. <el-date-picker
  28. v-model="startTime"
  29. :clearable="false"
  30. type="date"
  31. placeholder="选择保养开始时间"
  32. :picker-options="pickerOptions"
  33. value-format="yyyy-MM-dd"
  34. />
  35. </div>
  36. <div v-if="judgeShow>0 && judgeShow<7" class="maintenanceCycle" style="align-items: baseline;">
  37. <div class="maintenanceFont">{{ cycleOptions[judgeShow].label }}日期:</div>
  38. <div>
  39. <div v-if="judgeShow==1" class="maintenanceCycle marginNone">
  40. <el-checkbox-group v-for="(item,i) in weekList" :key="i" v-model="dayCheckList" style="margin-right:1%;">
  41. <el-checkbox class="rightMargin" :label="item" />
  42. </el-checkbox-group>
  43. </div>
  44. <el-select v-if="judgeShow==2" v-model="monthDateValue" clearable placeholder="请选择">
  45. <el-option
  46. v-for="item in monthDateOptions"
  47. :key="item.value"
  48. :label="item.label"
  49. :value="item.value"
  50. />
  51. </el-select>
  52. <el-radio-group v-if="judgeShow==3" v-model="weekDateValue">
  53. <el-radio v-for="(item,i) in weekList" :key="i" :label="item">{{ item }}</el-radio>
  54. </el-radio-group>
  55. <el-select v-if="judgeShow==4" v-model="quarterDateValue" clearable placeholder="请选择">
  56. <el-option
  57. v-for="item in qmonthDateOptions"
  58. :key="item.value"
  59. :label="item.label"
  60. :value="item.value"
  61. />
  62. </el-select>
  63. <el-select v-if="judgeShow==5" v-model="midyearDateValue" clearable placeholder="请选择">
  64. <el-option
  65. v-for="item in mymonthDateOptions"
  66. :key="item.value"
  67. :label="item.label"
  68. :value="item.value"
  69. />
  70. </el-select>
  71. <el-select v-if="judgeShow==6" v-model="yearDateValue" clearable placeholder="请选择">
  72. <el-option
  73. v-for="item in ymonthDateOptions"
  74. :key="item.value"
  75. :label="item.label"
  76. :value="item.value"
  77. />
  78. </el-select>
  79. <div v-if="periodDayDate!=''&&judgeShow==1" class="describe">下次维护日期为 <span class="fontColor">{{ periodDayDate }}</span></div>
  80. <div v-if="periodWeekDate!=''&&judgeShow==3" class="describe">下次维护日期为 <span class="fontColor">{{ periodWeekDate }}</span></div>
  81. <div v-if="periodMonthDate!=''&&judgeShow==2" class="describe">下次维护日期为 <span class="fontColor">{{ periodMonthDate }}</span></div>
  82. <div v-if="periodQuarterDate!=''&&judgeShow==4" class="describe">下次维护日期为 <span class="fontColor">{{ periodQuarterDate }}</span></div>
  83. <div v-if="periodMidYearDate!=''&&judgeShow==5" class="describe">下次维护日期为 <span class="fontColor">{{ periodMidYearDate }}</span></div>
  84. <div v-if="periodYearDate!=''&&judgeShow==6" class="describe">下次维护日期为 <span class="fontColor">{{ periodYearDate }}</span></div>
  85. </div>
  86. </div>
  87. <div class="maintenanceCycle" style="align-items: normal;">
  88. <div class="maintenanceFont">维护项目:</div>
  89. <el-input
  90. v-model="maintenanceTextarea"
  91. style="width:50%;"
  92. type="textarea"
  93. placeholder="请输入内容"
  94. maxlength="500"
  95. show-word-limit
  96. />
  97. </div>
  98. <div slot="footer" class="el-dialog--center">
  99. <ibps-toolbar :actions="editFromType != 'consult' ? toolbars : toolbarsConsult" @action-event="handleActionEvent" />
  100. </div>
  101. </el-dialog>
  102. </template>
  103. <script>
  104. import ActionUtils from '@/utils/action'
  105. import Vue from 'vue'
  106. // Vue.component('ibps-formrender', () => import('@/business/platform/form/formrender/index.vue'))
  107. export default {
  108. props: {
  109. visible: {
  110. type: Boolean,
  111. default: false
  112. },
  113. title: {
  114. type: String
  115. },
  116. customClass: {
  117. type: String
  118. },
  119. width: {
  120. type: String,
  121. default: '80%'
  122. },
  123. top: {
  124. type: String,
  125. default: '10%'
  126. },
  127. editFromType: {
  128. type: String,
  129. default: 'add'
  130. },
  131. dynamicParams: {
  132. type: Object
  133. },
  134. templateKey: {
  135. type: String,
  136. default: ''
  137. }
  138. },
  139. data () {
  140. const lunarGeneration = (sum) => {
  141. const arr = []
  142. for (let i = 1; i < sum; i++) {
  143. const mid = { value: '', label: '' }
  144. mid.value = '第' + i + '日'
  145. mid.label = '第' + i + '日'
  146. arr.push(mid)
  147. }
  148. return arr
  149. }
  150. const monthLunarGeneration = (sum) => {
  151. const arr = []
  152. for (let i = 1; i < sum; i++) {
  153. const mid = { value: '', label: '' }
  154. mid.value = '第' + i + '个月'
  155. mid.label = '第' + i + '个月'
  156. arr.push(mid)
  157. }
  158. return arr
  159. }
  160. const formatCurrentDate = () => {
  161. const today = new Date()
  162. const year = today.getFullYear()
  163. const month = (today.getMonth() + 1).toString().padStart(2, '0')
  164. const day = today.getDate().toString().padStart(2, '0')
  165. return `${year}-${month}-${day}`
  166. }
  167. return {
  168. pickerOptions: {
  169. disabledDate (time) {
  170. return time.getTime() < (Date.now() - (24 * 60 * 1000 * 60))
  171. }
  172. },
  173. qrCode: '',
  174. dialogVisible: this.visible,
  175. cycleOptions: [{
  176. value: '按需保养',
  177. label: '按需保养'
  178. }, {
  179. value: '日保养',
  180. label: '日保养'
  181. }, {
  182. value: '月保养',
  183. label: '月保养'
  184. }, {
  185. value: '周保养',
  186. label: '周保养'
  187. }, {
  188. value: '季度保养',
  189. label: '季度保养'
  190. }, {
  191. value: '半年保养',
  192. label: '半年保养'
  193. }, {
  194. value: '年保养',
  195. label: '年保养'
  196. }, {
  197. value: '间隔保养',
  198. label: '按时间间隔保养'
  199. }],
  200. cycleValue: '',
  201. qmonthDateOptions: monthLunarGeneration(4),
  202. ymonthDateOptions: monthLunarGeneration(13),
  203. mymonthDateOptions: monthLunarGeneration(7),
  204. monthDateOptions: lunarGeneration(29),
  205. monthDateValue: '',
  206. weekList: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
  207. quarterList: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],
  208. midList: [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]],
  209. dayCheckList: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
  210. maintenanceTextarea: '',
  211. toolbars: [
  212. { key: 'confirm', label: '确定' },
  213. { key: 'cancel' }
  214. ],
  215. toolbarsConsult: [{ key: 'cancel' }],
  216. weekDateValue: '',
  217. quarterDateValue: '',
  218. midyearDateValue: '',
  219. yearDateValue: '',
  220. sepValue: '',
  221. startTime: '',
  222. periodDayDate: '',
  223. periodWeekDate: '',
  224. periodMonthDate: '',
  225. periodQuarterDate: '',
  226. periodMidYearDate: '',
  227. periodYearDate: '',
  228. nowData: formatCurrentDate(),
  229. judgeShow: 0,
  230. daysOfWeek: [7, 1, 2, 3, 4, 5, 6]
  231. }
  232. },
  233. watch: {
  234. visible: {
  235. handler: function (val, oldVal) {
  236. this.dialogVisible = this.visible
  237. },
  238. immediate: true
  239. },
  240. cycleValue: {
  241. handler: function (val, oldVal) {
  242. if (val === '日保养') {
  243. this.judgeShow = 1
  244. } else if (val === '月保养') {
  245. this.judgeShow = 2
  246. } else if (val === '周保养') {
  247. this.judgeShow = 3
  248. } else if (val === '季度保养') {
  249. this.judgeShow = 4
  250. } else if (val === '半年保养') {
  251. this.judgeShow = 5
  252. } else if (val === '年保养') {
  253. this.judgeShow = 6
  254. } else if (val === '间隔保养') {
  255. this.judgeShow = 7
  256. } else {
  257. this.judgeShow = 0
  258. }
  259. },
  260. immediate: true
  261. },
  262. dayCheckList: {
  263. handler: function (val, oldVal) {
  264. const today = new Date()
  265. const dayOfWeekNumber = this.daysOfWeek[today.getDay()]
  266. const weekNum = []
  267. val.forEach((item, i) => {
  268. const num = this.weekList.findIndex(e => e == item) + 1
  269. weekNum.push(num)
  270. })
  271. weekNum.sort(function (a, b) {
  272. return a - b
  273. })
  274. const num = weekNum.findIndex(e => e > dayOfWeekNumber)
  275. if (val.length > 0 && num != -1) {
  276. this.periodDayDate = this.getDayDate(weekNum[num], 0)
  277. } else if (val.length > 0 && num == -1) {
  278. this.periodDayDate = this.getDayDate(weekNum[0], 1)
  279. } else {
  280. this.periodDayDate = ''
  281. }
  282. },
  283. immediate: true
  284. },
  285. weekDateValue: {
  286. handler: function (val, oldVal) {
  287. const today = new Date()
  288. const dayOfWeekNumber = this.daysOfWeek[today.getDay()]
  289. const weekNum = []
  290. const num1 = this.weekList.findIndex(e => e == val) + 1
  291. weekNum.push(num1)
  292. const num = weekNum.findIndex(e => e > dayOfWeekNumber)
  293. if (val != '' && num != -1) {
  294. this.periodWeekDate = this.getDayDate(weekNum[0], 0)
  295. } else if (val != '' && num == -1) {
  296. this.periodWeekDate = this.getDayDate(weekNum[0], 1)
  297. } else {
  298. this.periodWeekDate = ''
  299. }
  300. },
  301. immediate: true
  302. },
  303. monthDateValue: {
  304. handler: function (val, oldVal) {
  305. const turnVal = val.replace(/[^0-9]/ig, '')
  306. const today = new Date()
  307. const day = today.getDate()
  308. const nextMonth = this.getNextMonthDate(today, turnVal, 1)
  309. const currentMonth = this.getNextMonthDate(today, turnVal, 0)
  310. this.periodMonthDate = turnVal > day ? currentMonth : nextMonth
  311. }
  312. // immediate: true
  313. },
  314. quarterDateValue: {
  315. handler: function (val, oldVal) {
  316. const turnVal = val.replace(/[^0-9]/ig, '')
  317. const today = new Date()
  318. const month = today.getMonth() + 1
  319. const qu = this.getQuarter(today)
  320. const nowM = this.quarterList[qu - 1][turnVal - 1]
  321. const nextM = this.quarterList[qu % 4][turnVal - 1]
  322. const endMonth = month >= nowM ? nextM : nowM
  323. const yearPJ = today.getFullYear()
  324. const monthPJ = endMonth > 9 ? endMonth : '0' + endMonth
  325. this.periodQuarterDate = yearPJ + '-' + monthPJ + '-01'
  326. }
  327. // immediate: true
  328. },
  329. midyearDateValue: {
  330. handler: function (val, oldVal) {
  331. const turnVal = val.replace(/[^0-9]/ig, '')
  332. const today = new Date()
  333. const month = today.getMonth() + 1
  334. const qu = month > 6 ? 2 : 1
  335. const nowM = this.midList[qu - 1][turnVal - 1]
  336. const nextM = this.midList[qu % 2][turnVal - 1]
  337. const endMonth = month >= nowM ? nextM : nowM
  338. const yearPJ = month >= nowM ? today.getFullYear() + 1 : today.getFullYear()
  339. const monthPJ = endMonth > 9 ? endMonth : '0' + endMonth
  340. this.periodMidYearDate = yearPJ + '-' + monthPJ + '-01'
  341. }
  342. // immediate: true
  343. },
  344. yearDateValue: {
  345. handler: function (val, oldVal) {
  346. const turnVal = val.replace(/[^0-9]/ig, '')
  347. const today = new Date()
  348. const month = today.getMonth() + 1
  349. const year = today.getFullYear()
  350. const qu = month >= turnVal ? year + 1 : year
  351. const monthPJ = turnVal > 9 ? turnVal : '0' + turnVal
  352. this.periodYearDate = qu + '-' + monthPJ + '-01'
  353. }
  354. // immediate: true
  355. }
  356. },
  357. created () {
  358. this.loadFormData()
  359. },
  360. methods: {
  361. handleActionEvent ({ key }) {
  362. switch (key) {
  363. case 'confirm':
  364. if (this.dynamicParams.customComponent) {
  365. this.handleConfirmV2(key)
  366. } else {
  367. this.handleConfirm(key)
  368. }
  369. break
  370. case 'cancel':
  371. this.closeDialog()
  372. break
  373. default:
  374. break
  375. }
  376. },
  377. // 自定义组件中
  378. handleConfirmV2 (key) {
  379. const val = this.corresponding(this.cycleValue)
  380. const valNum = this.correspondingNum(this.cycleValue)
  381. if (this.cycleValue !== '按需保养' && this.cycleValue !== '' && val !== '' && valNum !== '' && this.maintenanceTextarea !== '') {
  382. if (this.cycleValue === '间隔保养') {
  383. if (!this.startTime) {
  384. return this.$message.warning('请选择开始保养时间')
  385. } else {
  386. this.$emit('submit', { weiHuLeiXing: this.cycleValue, weiHuRiQi: val, riQiShuZi: valNum, weiHuXiangMuC: this.maintenanceTextarea, kaiShiShiJian: this.startTime, index: this.dynamicParams?.index })
  387. this.closeDialog()
  388. }
  389. } else {
  390. this.$emit('submit', { weiHuLeiXing: this.cycleValue, weiHuRiQi: val, riQiShuZi: valNum, weiHuXiangMuC: this.maintenanceTextarea, index: this.dynamicParams?.index })
  391. this.closeDialog()
  392. }
  393. } else if (this.cycleValue === '按需保养' && this.cycleValue !== '' && this.maintenanceTextarea !== '') {
  394. this.$emit('submit', { weiHuLeiXing: this.cycleValue, weiHuXiangMuC: this.maintenanceTextarea, index: this.dynamicParams?.index })
  395. this.closeDialog()
  396. } else {
  397. this.$message.warning('请保证所有信息都已填写')
  398. }
  399. },
  400. handleConfirm (key) {
  401. const a = this.dynamicParams.formObj.getData(this.templateKey)
  402. const val = this.corresponding(this.cycleValue)
  403. const valNum = this.correspondingNum(this.cycleValue)
  404. if (this.cycleValue != '按需保养' && this.cycleValue != '' && val != '' && valNum != '' && this.maintenanceTextarea != '') {
  405. if (this.dynamicParams.position == 'manage') {
  406. this.$set(a, this.dynamicParams.params.index, { ...a[this.dynamicParams.params.index], weiHuLeiXing: this.cycleValue, weiHuRiQi: val, riQiShuZi: valNum, weiHuXiangMuC: this.maintenanceTextarea })
  407. } else {
  408. a.push({ weiHuLeiXing: this.cycleValue, weiHuRiQi: val, riQiShuZi: valNum, weiHuXiangMuC: this.maintenanceTextarea })
  409. }
  410. // this.$nextTick(function(){
  411. this.dynamicParams.formObj.setData(this.templateKey, a)
  412. // })
  413. this.closeDialog()
  414. } else if (this.cycleValue == '按需保养' && this.cycleValue != '' && this.maintenanceTextarea != '') {
  415. if (this.dynamicParams.position == 'manage') {
  416. this.$set(a, this.dynamicParams.params.index, { weiHuLeiXing: this.cycleValue, weiHuXiangMuC: this.maintenanceTextarea })
  417. } else {
  418. a.push({ weiHuLeiXing: this.cycleValue, weiHuXiangMuC: this.maintenanceTextarea })
  419. }
  420. // this.$nextTick(function(){
  421. this.dynamicParams.formObj.setData(this.templateKey, a)
  422. // })
  423. this.closeDialog()
  424. } else {
  425. this.dynamicParams.formObj.$message.warning('请保证所有信息都已填写')
  426. }
  427. },
  428. corresponding (content) {
  429. const that = this
  430. if (content === '日保养') {
  431. let str = '每周'
  432. const numArr = []
  433. that.dayCheckList.forEach((element, i) => {
  434. const ind = that.weekList.findIndex(item => item === element) != -1 ? that.weekList.findIndex(item => item === element) + 1 : ''
  435. numArr.push(ind)
  436. })
  437. numArr.sort(function (a, b) {
  438. return a - b
  439. })
  440. numArr.forEach((element, i) => {
  441. if (i === that.dayCheckList.length - 1) {
  442. str = str + element
  443. } else {
  444. str = str + element + ','
  445. }
  446. })
  447. return str === '每周1,2,3,4,5,6,7' ? '每天' : str
  448. } else if (content === '月保养') {
  449. return '每月' + that.monthDateValue
  450. } else if (content === '周保养') {
  451. const ind = that.weekList.findIndex(item => item === that.weekDateValue) !== -1 ? that.weekList.findIndex(item => item === that.weekDateValue) + 1 : ''
  452. return '每周' + ind
  453. } else if (content === '季度保养') {
  454. return '每季度' + that.quarterDateValue
  455. } else if (content === '半年保养') {
  456. return '每半年' + that.midyearDateValue
  457. } else if (content === '年保养') {
  458. return '每年' + that.yearDateValue
  459. } else if (content === '间隔保养') {
  460. return `${this.startTime}起每隔${this.sepValue}天`
  461. } else {
  462. return ''
  463. }
  464. },
  465. correspondingNum (content) {
  466. const that = this
  467. if (content === '日保养') {
  468. let str = ''
  469. const numArr = []
  470. that.dayCheckList.forEach((element, i) => {
  471. const ind = that.weekList.findIndex(item => item === element) + 1
  472. numArr.push(ind)
  473. })
  474. numArr.sort(function (a, b) {
  475. return a - b
  476. })
  477. numArr.forEach((element, i) => {
  478. if (i === that.dayCheckList.length - 1) {
  479. str = str + element
  480. } else {
  481. str = str + element + ','
  482. }
  483. })
  484. return str
  485. } else if (content === '月保养') {
  486. const turnVal = that.monthDateValue.replace(/[^0-9]/ig, '')
  487. return turnVal
  488. } else if (content === '周保养') {
  489. const ind = that.weekList.findIndex(item => item === that.weekDateValue) !== -1 ? that.weekList.findIndex(item => item === that.weekDateValue) + 1 : ''
  490. return ind
  491. } else if (content === '季度保养') {
  492. const turnVal = that.quarterDateValue.replace(/[^0-9]/ig, '')
  493. return turnVal
  494. } else if (content === '半年保养') {
  495. const turnVal = that.midyearDateValue.replace(/[^0-9]/ig, '')
  496. return turnVal
  497. } else if (content === '年保养') {
  498. const turnVal = that.yearDateValue.replace(/[^0-9]/ig, '')
  499. return turnVal
  500. } else if (content === '间隔保养') {
  501. const turnVal = that.sepValue
  502. return turnVal
  503. } else {
  504. return ''
  505. }
  506. },
  507. assignment (content) {
  508. const that = this
  509. if (content.weiHuLeiXing === '日保养') {
  510. const strArr = []
  511. const str = content.weiHuRiQi === '每天' ? '1,2,3,4,5,6,7' : content.weiHuRiQi.slice(2)
  512. const partArr = str.split(',')
  513. // console.log(partArr)
  514. partArr.forEach((e, i) => {
  515. const num = e * 1 - 1
  516. strArr.push(this.weekList[num])
  517. })
  518. this.dayCheckList = strArr
  519. } else if (content.weiHuLeiXing === '月保养') {
  520. that.monthDateValue = content.weiHuRiQi.slice(2)
  521. } else if (content.weiHuLeiXing === '周保养') {
  522. const str = content.weiHuRiQi.slice(2)
  523. const partArr = str.split(',')
  524. // console.log(partArr*1-1)
  525. that.weekDateValue = this.weekList[partArr * 1 - 1]
  526. } else if (content.weiHuLeiXing === '季度保养') {
  527. that.quarterDateValue = content.weiHuRiQi.slice(3)
  528. } else if (content.weiHuLeiXing === '半年保养') {
  529. that.midyearDateValue = content.weiHuRiQi.slice(3)
  530. } else if (content.weiHuLeiXing === '年保养') {
  531. that.yearDateValue = content.weiHuRiQi.slice(2)
  532. } else if (content.weiHuLeiXing === '间隔保养') {
  533. that.sepValue = +content.riQiShuZi || ''
  534. that.startTime = content.kaiShiShiJian || ''
  535. } else {
  536. }
  537. },
  538. // 关闭当前窗口
  539. closeDialog () {
  540. this.$emit('close', false)
  541. },
  542. loadFormData () {
  543. if (this.dynamicParams.position == 'manage') {
  544. const a = this.dynamicParams.formObj.getData(this.templateKey)[this.dynamicParams.params.index]
  545. this.assignment(a)
  546. this.cycleValue = a.weiHuLeiXing
  547. this.maintenanceTextarea = a.weiHuXiangMuC
  548. }
  549. if (this.dynamicParams.customComponent && this.dynamicParams.row) {
  550. const a = this.dynamicParams.row
  551. this.assignment(a)
  552. this.cycleValue = a.weiHuLeiXing
  553. this.maintenanceTextarea = a.weiHuXiangMuC
  554. }
  555. },
  556. getDayDate (type, dates) {
  557. const now = new Date()
  558. const nowTime = now.getTime()
  559. const day = now.getDay()
  560. const longTime = 24 * 60 * 60 * 1000
  561. const n = longTime * 7 * (dates || 0)
  562. let dd = nowTime - (day - type) * longTime + n
  563. dd = new Date(dd)
  564. const y = dd.getFullYear()
  565. let m = dd.getMonth() + 1
  566. let d = dd.getDate()
  567. m = m < 10 ? '0' + m : m
  568. d = d < 10 ? '0' + d : d
  569. const daynow = y + '-' + m + '-' + d
  570. return daynow
  571. },
  572. // 获取往后几个月相应的日期
  573. // currentDate:当前日期
  574. // dayOfMonth:获取几号
  575. // val:往后几个月
  576. getNextMonthDate (currentDate, dayOfMonth, val) {
  577. const currentYear = currentDate.getFullYear()
  578. const currentMonth = currentDate.getMonth()
  579. const nextMonth = currentMonth + val
  580. const nextMonthDate = new Date(currentYear, nextMonth, dayOfMonth)
  581. const formattedDate = nextMonthDate.toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')
  582. return formattedDate
  583. },
  584. // 获取当前季度
  585. getQuarter (date) {
  586. return Math.floor(date.getMonth() / 3) + 1
  587. }
  588. }
  589. }
  590. </script>
  591. <style lang="scss" >
  592. .form-renderer-dialog {
  593. .el-dialog__body {
  594. padding: 10px 0 5px 0;
  595. }
  596. .el-dialog__headerbtn {
  597. z-index: 99999;
  598. }
  599. @media print {
  600. .el-dialog__headerbtn {
  601. display: none !important;
  602. }
  603. .hidden-print {
  604. padding: 0;
  605. margin: 0;
  606. }
  607. }
  608. }
  609. .maintenanceCycle{
  610. display: flex;
  611. align-items: center;
  612. margin: 2%;
  613. }
  614. .maintenanceFont{
  615. width: 10%;
  616. }
  617. .marginNone{
  618. margin: 0;
  619. }
  620. .rightMargin{
  621. margin-right: 2.5vh !important;
  622. }
  623. .describe{
  624. margin-top: 2%;
  625. font-size: 12px;
  626. color: #808080;
  627. }
  628. .fontColor{
  629. color: #409EFF;
  630. }
  631. </style>