You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

917 lines
29 KiB

4 years ago
  1. <template>
  2. <div class="customer-css">
  3. <el-dialog title="批量维护工作日历" v-drag v-bind="$attrs" v-on="$listeners" width="800px" class="customer-dialog" >
  4. <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -5px;">
  5. <el-form-item :label="'日历编码:'">
  6. <el-input v-model="calendarSearchData.calendarId" style="width: 130px"></el-input>
  7. </el-form-item>
  8. <el-form-item :label="'日历描述:'">
  9. <el-input v-model="calendarSearchData.calendarDesc" style="width: 130px"></el-input>
  10. </el-form-item>
  11. <el-form-item :label="'起始时间:'">
  12. <el-date-picker
  13. style="width: 130px"
  14. v-model="calendarSearchData.startDate"
  15. value-format="yyyy-MM-dd"
  16. placeholder="选择日期">
  17. </el-date-picker>
  18. </el-form-item>
  19. <el-form-item :label="'工作日类型:'">
  20. <el-select v-model="calendarSearchData.datetype" style="width: 130px"
  21. placeholder="请选择">
  22. <el-option
  23. v-for="(item, index) in selectList"
  24. :key="index"
  25. :label="item.label"
  26. :value="item.value">
  27. </el-option>
  28. </el-select>
  29. <el-button @click="refreshModel()" type="primary" style="margin-top: 0px">{{'查询'}}</el-button>
  30. <el-button @click="saveList()" type="primary" style="margin-top: 0px">{{'保存日历'}}</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <div class="calendar">
  34. <el-table
  35. height="400"
  36. :data="dataList3"
  37. border
  38. :vertical-align="'middle'"
  39. @selection-change="selectionChangeHandle"
  40. style="width: 100%;"
  41. :row-style="{height:'20px'}">
  42. <el-table-column
  43. v-for="(item,index) in columnList3" :key="index"
  44. :sortable="item.columnSortable"
  45. :prop="item.columnProp"
  46. :header-align="item.headerAlign"
  47. :show-overflow-tooltip="item.showOverflowTooltip"
  48. :align="item.align"
  49. :fixed="item.fixed"
  50. :width="item.columnWidth"
  51. :label="item.columnLabel">
  52. <template slot-scope="scope">
  53. <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
  54. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  55. style="width: 100px; height: 80px"/></span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. type="selection"
  60. align="center"
  61. width="30px">
  62. </el-table-column>
  63. <el-table-column
  64. prop="val0"
  65. header-align="center"
  66. align="left"
  67. :label="this.timeArray[0]">
  68. <template slot-scope="scope">
  69. <el-select v-model="scope.row.val0" placeholder="请选择" style="height: 12px;padding: 0px " filterable allow-create>
  70. <el-option v-for="item in selectList " :key="index" :label="item.label" :value="item.value">
  71. </el-option>
  72. </el-select>
  73. </template>
  74. </el-table-column>
  75. <el-table-column
  76. prop="val1"
  77. header-align="center"
  78. align="left"
  79. :label="this.timeArray[1]">
  80. <template slot-scope="scope">
  81. <el-select v-model="scope.row.val1" placeholder="请选择" style="height: 12px;padding: 0px " filterable allow-create>
  82.  <el-option v-for="item in selectList " :key="index" :label="item.label" :value="item.value">
  83.  </el-option>
  84. </el-select>
  85. </template>
  86. </el-table-column>
  87. <el-table-column
  88. prop="val2"
  89. header-align="center"
  90. align="left"
  91. :label="this.timeArray[2]">
  92. <template slot-scope="scope">
  93. <el-select v-model="scope.row.val2" placeholder="请选择" style="height: 12px;padding: 0px " filterable allow-create>
  94.  <el-option v-for="item in selectList " :key="index" :label="item.label" :value="item.value">
  95.  </el-option>
  96. </el-select>
  97. </template>
  98. </el-table-column>
  99. <el-table-column
  100. prop="val3"
  101. header-align="center"
  102. align="left"
  103. :label="this.timeArray[3]">
  104. <template slot-scope="scope">
  105. <el-select v-model="scope.row.val3" placeholder="请选择" style="height: 12px;padding: 0px " filterable allow-create>
  106.  <el-option v-for="item in selectList " :key="index" :label="item.label" :value="item.value">
  107.  </el-option>
  108. </el-select>
  109. </template>
  110. </el-table-column>
  111. <el-table-column
  112. prop="val4"
  113. header-align="center"
  114. align="left"
  115. :label="this.timeArray[4]">
  116. <template slot-scope="scope">
  117. <el-select v-model="scope.row.val4" placeholder="请选择" style="height: 12px;padding: 0px " filterable allow-create>
  118.  <el-option v-for="item in selectList " :key="index" :label="item.label" :value="item.value">
  119.  </el-option>
  120. </el-select>
  121. </template>
  122. </el-table-column>
  123. <el-table-column
  124. prop="val5"
  125. header-align="center"
  126. align="left"
  127. :label="this.timeArray[5]">
  128. <template slot-scope="scope">
  129. <el-select v-model="scope.row.val5" placeholder="请选择" style="height: 12px;padding: 0px " filterable allow-create>
  130.  <el-option v-for="item in selectList " :key="index" :label="item.label" :value="item.value">
  131.  </el-option>
  132. </el-select>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. prop="val6"
  137. header-align="center"
  138. align="left"
  139. :label="this.timeArray[6]">
  140. <template slot-scope="scope">
  141. <el-select v-model="scope.row.val6" placeholder="请选择" style="height: 12px;padding: 0px " filterable allow-create>
  142.  <el-option v-for="item in selectList " :key="index" :label="item.label" :value="item.value">
  143.  </el-option>
  144. </el-select>
  145. </template>
  146. </el-table-column>
  147. <el-table-column
  148. prop="val7"
  149. header-align="center"
  150. align="left"
  151. :label="this.timeArray[7]">
  152. <template slot-scope="scope">
  153. <el-select v-model="scope.row.val7" placeholder="请选择" style="height: 12px;padding: 0px " filterable allow-create>
  154.  <el-option v-for="item in selectList " :key="index" :label="item.label" :value="item.value">
  155.  </el-option>
  156. </el-select>
  157. </template>
  158. </el-table-column>
  159. <el-table-column
  160. prop="val8"
  161. header-align="center"
  162. align="left"
  163. :label="this.timeArray[8]">
  164. <template slot-scope="scope">
  165. <el-select v-model="scope.row.val8" placeholder="请选择" style="height: 12px;padding: 0px " filterable allow-create>
  166.  <el-option v-for="item in selectList " :key="index" :label="item.label" :value="item.value">
  167.  </el-option>
  168. </el-select>
  169. </template>
  170. </el-table-column>
  171. </el-table>
  172. </div>
  173. <el-footer style="height:40px;margin-top: 20px;text-align:center" >
  174. <el-button type="primary" @click="closeDialog">关闭</el-button>
  175. </el-footer>
  176. </el-dialog>
  177. </div>
  178. </template>
  179. <script>
  180. import {
  181. getCalendarData,
  182. saveCalendar,
  183. delCalendar,
  184. calendarDatetypeInfo,
  185. batchSaveCDData,
  186. }from "@/api/base.js"
  187. export default {
  188. name: "calendar",
  189. data () {
  190. return {
  191. selectList:[],
  192. calendarModelFlag:false,
  193. calendarModelDisableFlag:false,
  194. newCalendarData:{
  195. site:'',
  196. calendarId:'',
  197. calendarDesc:'',
  198. status:'使用中',
  199. id:0,
  200. },
  201. columnList:[
  202. {
  203. userId: this.$store.state.user.name,
  204. functionId: 6038,
  205. serialNumber: '6038TableSite',
  206. tableId: "6038Table",
  207. tableName: "工作日类型表",
  208. columnProp: "site",
  209. headerAlign: "center",
  210. align: "left",
  211. columnLabel: "工厂编号",
  212. columnHidden: false,
  213. columnImage: false,
  214. columnSortable: false,
  215. sortLv: 0,
  216. status: true,
  217. fixed: false,
  218. columnWidth: 100
  219. },
  220. {
  221. userId: this.$store.state.user.name,
  222. functionId: 6038,
  223. serialNumber: '6038TableCalendarId',
  224. tableId: "6038Table",
  225. tableName: "工作日类型表",
  226. columnProp: "calendarId",
  227. headerAlign: "center",
  228. align: "left",
  229. columnLabel: "日历编码",
  230. columnHidden: false,
  231. columnImage: false,
  232. columnSortable: false,
  233. sortLv: 0,
  234. status: true,
  235. fixed: false,
  236. columnWidth: 100
  237. },
  238. {
  239. userId: this.$store.state.user.name,
  240. functionId: 6038,
  241. serialNumber: '6038TableCalendarDesc',
  242. tableId: "6038Table",
  243. tableName: "工作日类型表",
  244. columnProp: "calendarDesc",
  245. headerAlign: "center",
  246. align: "left",
  247. columnLabel: "日历描述",
  248. columnHidden: false,
  249. columnImage: false,
  250. columnSortable: false,
  251. sortLv: 0,
  252. status: true,
  253. fixed: false,
  254. columnWidth: 160
  255. },
  256. {
  257. userId: this.$store.state.user.name,
  258. functionId: 6038,
  259. serialNumber: '6038TableStatus',
  260. tableId: "6038Table",
  261. tableName: "工作日类型表",
  262. columnProp: "status",
  263. headerAlign: "center",
  264. align: "left",
  265. columnLabel: "使用状态",
  266. columnHidden: false,
  267. columnImage: false,
  268. columnSortable: false,
  269. sortLv: 0,
  270. status: true,
  271. fixed: false,
  272. columnWidth: 100
  273. },
  274. ],
  275. columnList2: [
  276. {
  277. userId: this.$store.state.user.name,
  278. functionId: 6038,
  279. serialNumber: '6038Table2Scheduledate',
  280. tableId: "6038Table2",
  281. tableName: "工作日历表2",
  282. columnProp: "scheduledate",
  283. headerAlign: "center",
  284. align: "left",
  285. columnLabel: "日期",
  286. columnHidden: false,
  287. columnImage: false,
  288. columnSortable: false,
  289. sortLv: 0,
  290. status: true,
  291. fixed: false,
  292. columnWidth: 100
  293. },
  294. {
  295. userId: this.$store.state.user.name,
  296. functionId: 6038,
  297. serialNumber: '6038Table2Datetype',
  298. tableId: "6038Table2",
  299. tableName: "工作日历表2",
  300. columnProp: "datetype",
  301. headerAlign: "center",
  302. align: "left",
  303. columnLabel: "工作日类型",
  304. columnHidden: false,
  305. columnImage: false,
  306. columnSortable: false,
  307. sortLv: 0,
  308. status: true,
  309. fixed: false,
  310. columnWidth: 100
  311. },
  312. {
  313. userId: this.$store.state.user.name,
  314. functionId: 6038,
  315. serialNumber: '6038Table2Worktime',
  316. tableId: "6038Table2",
  317. tableName: "工作日历表2",
  318. columnProp: "worktime",
  319. headerAlign: "center",
  320. align: "right",
  321. columnLabel: "累计工作时间",
  322. columnHidden: false,
  323. columnImage: false,
  324. columnSortable: false,
  325. sortLv: 0,
  326. status: true,
  327. fixed: false,
  328. columnWidth: 100
  329. },
  330. {
  331. userId: this.$store.state.user.name,
  332. functionId: 6038,
  333. serialNumber: '6038Table2Exceptexacttime1',
  334. tableId: "6038Table2",
  335. tableName: "工作日历表2",
  336. columnProp: "exceptexacttime1",
  337. headerAlign: "center",
  338. align: "left",
  339. columnLabel: "休息时间点1",
  340. columnHidden: false,
  341. columnImage: false,
  342. columnSortable: false,
  343. sortLv: 0,
  344. status: true,
  345. fixed: false,
  346. columnWidth: 100
  347. },
  348. {
  349. userId: this.$store.state.user.name,
  350. functionId: 6038,
  351. serialNumber: '6038Table2Exceptduration1',
  352. tableId: "6038Table2",
  353. tableName: "工作日历表2",
  354. columnProp: "exceptduration1",
  355. headerAlign: "center",
  356. align: "right",
  357. columnLabel: "休息时长1",
  358. columnHidden: false,
  359. columnImage: false,
  360. columnSortable: false,
  361. sortLv: 0,
  362. status: true,
  363. fixed: false,
  364. columnWidth: 100
  365. },
  366. {
  367. userId: this.$store.state.user.name,
  368. functionId: 6038,
  369. serialNumber: '6038Table2Exceptexacttime2',
  370. tableId: "6038Table2",
  371. tableName: "工作日历表2",
  372. columnProp: "exceptexacttime2",
  373. headerAlign: "center",
  374. align: "left",
  375. columnLabel: "休息时间点2",
  376. columnHidden: false,
  377. columnImage: false,
  378. columnSortable: false,
  379. sortLv: 0,
  380. status: true,
  381. fixed: false,
  382. columnWidth: 100
  383. },
  384. {
  385. userId: this.$store.state.user.name,
  386. functionId: 6038,
  387. serialNumber: '6038Table2Exceptduration2',
  388. tableId: "6038Table2",
  389. tableName: "工作日历表2",
  390. columnProp: "exceptduration2",
  391. headerAlign: "center",
  392. align: "right",
  393. columnLabel: "休息时长2",
  394. columnHidden: false,
  395. columnImage: false,
  396. columnSortable: false,
  397. sortLv: 0,
  398. status: true,
  399. fixed: false,
  400. columnWidth: 100
  401. },
  402. {
  403. userId: this.$store.state.user.name,
  404. functionId: 6038,
  405. serialNumber: '6038Table2Exceptexacttime3',
  406. tableId: "6038Table2",
  407. tableName: "工作日历表2",
  408. columnProp: "exceptexacttime3",
  409. headerAlign: "center",
  410. align: "left",
  411. columnLabel: "休息时间点3",
  412. columnHidden: false,
  413. columnImage: false,
  414. columnSortable: false,
  415. sortLv: 0,
  416. status: true,
  417. fixed: false,
  418. columnWidth: 100
  419. },
  420. {
  421. userId: this.$store.state.user.name,
  422. functionId: 6038,
  423. serialNumber: '6038Table2Exceptduration3',
  424. tableId: "6038Table2",
  425. tableName: "工作日历表2",
  426. columnProp: "exceptduration3",
  427. headerAlign: "center",
  428. align: "right",
  429. columnLabel: "休息时长3",
  430. columnHidden: false,
  431. columnImage: false,
  432. columnSortable: false,
  433. sortLv: 0,
  434. status: true,
  435. fixed: false,
  436. columnWidth: 100
  437. },
  438. {
  439. userId: this.$store.state.user.name,
  440. functionId: 6038,
  441. serialNumber: '6038Table2Exceptexacttime4',
  442. tableId: "6038Table2",
  443. tableName: "工作日历表2",
  444. columnProp: "exceptexacttime4",
  445. headerAlign: "center",
  446. align: "left",
  447. columnLabel: "休息时间点4",
  448. columnHidden: false,
  449. columnImage: false,
  450. columnSortable: false,
  451. sortLv: 0,
  452. status: true,
  453. fixed: false,
  454. columnWidth: 100
  455. },
  456. {
  457. userId: this.$store.state.user.name,
  458. functionId: 6038,
  459. serialNumber: '6038Table2Exceptduration4',
  460. tableId: "6038Table2",
  461. tableName: "工作日历表2",
  462. columnProp: "exceptduration4",
  463. headerAlign: "center",
  464. align: "right",
  465. columnLabel: "休息时长4",
  466. columnHidden: false,
  467. columnImage: false,
  468. columnSortable: false,
  469. sortLv: 0,
  470. status: true,
  471. fixed: false,
  472. columnWidth: 100
  473. },
  474. {
  475. userId: this.$store.state.user.name,
  476. functionId: 6038,
  477. serialNumber: '6038Table2Exceptexacttime5',
  478. tableId: "6038Table2",
  479. tableName: "工作日历表2",
  480. columnProp: "exceptexacttime5",
  481. headerAlign: "center",
  482. align: "left",
  483. columnLabel: "休息时间点5",
  484. columnHidden: false,
  485. columnImage: false,
  486. columnSortable: false,
  487. sortLv: 0,
  488. status: true,
  489. fixed: false,
  490. columnWidth: 100
  491. },
  492. {
  493. userId: this.$store.state.user.name,
  494. functionId: 6038,
  495. serialNumber: '6038Table2Exceptduration5',
  496. tableId: "6038Table2",
  497. tableName: "工作日历表2",
  498. columnProp: "exceptduration5",
  499. headerAlign: "center",
  500. align: "right",
  501. columnLabel: "休息时长5",
  502. columnHidden: false,
  503. columnImage: false,
  504. columnSortable: false,
  505. sortLv: 0,
  506. status: true,
  507. fixed: false,
  508. columnWidth: 100
  509. },
  510. {
  511. userId: this.$store.state.user.name,
  512. functionId: 6038,
  513. serialNumber: '6038Table2Exceptexacttime6',
  514. tableId: "6038Table2",
  515. tableName: "工作日历表2",
  516. columnProp: "exceptexacttime6",
  517. headerAlign: "center",
  518. align: "left",
  519. columnLabel: "休息时间点6",
  520. columnHidden: false,
  521. columnImage: false,
  522. columnSortable: false,
  523. sortLv: 0,
  524. status: true,
  525. fixed: false,
  526. columnWidth: 100
  527. },
  528. {
  529. userId: this.$store.state.user.name,
  530. functionId: 6038,
  531. serialNumber: '6038Table2Exceptduration6',
  532. tableId: "6038Table2",
  533. tableName: "工作日历表2",
  534. columnProp: "exceptduration6",
  535. headerAlign: "center",
  536. align: "right",
  537. columnLabel: "休息时长6",
  538. columnHidden: false,
  539. columnImage: false,
  540. columnSortable: false,
  541. sortLv: 0,
  542. status: true,
  543. fixed: false,
  544. columnWidth: 100
  545. }
  546. ],
  547. columnList3:[
  548. {
  549. userId: this.$store.state.user.name,
  550. functionId: 6038,
  551. serialNumber: '6038Table3Site',
  552. tableId: "6038Table3",
  553. tableName: "工作日历表3",
  554. columnProp: "site",
  555. headerAlign: "center",
  556. align: "left",
  557. columnLabel: "工厂编码",
  558. columnHidden: false,
  559. columnImage: false,
  560. columnSortable: false,
  561. sortLv: 0,
  562. status: true,
  563. fixed: false,
  564. columnWidth: 80
  565. },
  566. {
  567. userId: this.$store.state.user.name,
  568. functionId: 6038,
  569. serialNumber: '6038Table3CalendarId',
  570. tableId: "6038Table3",
  571. tableName: "工作日历表3",
  572. columnProp: "calendarId",
  573. headerAlign: "center",
  574. align: "left",
  575. columnLabel: "日历编码",
  576. columnHidden: false,
  577. columnImage: false,
  578. columnSortable: false,
  579. sortLv: 0,
  580. status: true,
  581. fixed: false,
  582. columnWidth: 80
  583. },
  584. {
  585. userId: this.$store.state.user.name,
  586. functionId: 6038,
  587. serialNumber: '6038Table3CalendarDesc',
  588. tableId: "6038Table3",
  589. tableName: "工作日历表3",
  590. columnProp: "calendarDesc",
  591. headerAlign: "center",
  592. align: "left",
  593. columnLabel: "日历描述",
  594. columnHidden: false,
  595. columnImage: false,
  596. columnSortable: false,
  597. sortLv: 0,
  598. status: true,
  599. fixed: false,
  600. columnWidth: 100
  601. },
  602. ],
  603. maintainColumnList2:[],
  604. height:'200',
  605. searchData:{
  606. site:'',
  607. calendarId:'',
  608. status:'使用中',
  609. },
  610. calendarSearchData:{
  611. site:this.$store.state.user.site.toString(),
  612. calendarId:'',
  613. calendarDesc:'',
  614. startDate:'',
  615. endDate:'',
  616. datetype:'',
  617. },
  618. dataList:[],
  619. dataList2:[],
  620. dataList3:[],
  621. timeArray:[],
  622. valueList:[],
  623. valList:[],
  624. dataListSelections:[],
  625. }
  626. },
  627. mounted() {
  628. this.$nextTick(()=>{
  629. this.height = window.innerHeight - 150;
  630. })
  631. },
  632. watch: {
  633. '$route' (to, from) {
  634. if(localStorage.getItem('calendar')!=undefined){
  635. this.jump();
  636. }
  637. }
  638. },
  639. methods: {
  640. //初始化页面的方法
  641. init(searchData){
  642. //设置参数
  643. this.calendarSearchData.startDate = searchData.scheduledDate;
  644. //调用方法
  645. this.maintainCalendar();
  646. },
  647. /*刷新页面的数据*/
  648. maintainCalendar(){
  649. this.getSelectData();
  650. this.calendarSearchData.calendarId = '';
  651. this.calendarSearchData.calendarDesc ='';
  652. //this.calendarSearchData.startDate = this.GetDateStr(0);
  653. this.calendarSearchData.endDate = this.GetDateStr(9);
  654. this.refreshModel();
  655. },
  656. jump(){
  657. let data=JSON.parse(localStorage.getItem('calendar'));
  658. localStorage.removeItem('calendar');
  659. getCalendarData(data).then(({data}) => {
  660. this.dataList = data.rows
  661. })
  662. },
  663. // 多选数据
  664. selectionChangeHandle (val) {
  665. this.dataListSelections = val
  666. },
  667. getData(){
  668. if(localStorage.getItem('calendar')!=undefined){
  669. this.jump();
  670. }else {
  671. getCalendarData(this.searchData).then(({data}) => {
  672. this.dataList = data.rows
  673. })
  674. }
  675. },
  676. newCalendarModel(){
  677. this.newCalendarData.id=0,
  678. this.newCalendarData.site=this.$store.state.user.site,
  679. this.newCalendarData.calendarId='',
  680. this.newCalendarData.calendarDesc='',
  681. this.newCalendarData.status='使用中',
  682. this.calendarModelDisableFlag=false;
  683. this.calendarModelFlag=true;
  684. },
  685. editData(row){
  686. this.newCalendarData.id=1,
  687. this.newCalendarData.site=row.site,
  688. this.newCalendarData.calendarId=row.calendarId,
  689. this.newCalendarData.calendarDesc=row.calendarDesc,
  690. this.newCalendarData.status=row.status,
  691. this.calendarModelDisableFlag=true;
  692. this.calendarModelFlag=true;
  693. },
  694. calendarSave(){
  695. saveCalendar(this.newCalendarData).then(({data}) => {
  696. if (data.code == 200) {
  697. this.getData()
  698. this.calendarModelFlag=false;
  699. this.$message({
  700. message: '操作成功',
  701. type: 'success',
  702. duration: 1500,
  703. onClose: () => {
  704. }
  705. })
  706. } else {
  707. this.$alert(data.msg, '错误', {
  708. confirmButtonText: '确定'
  709. })
  710. }
  711. })
  712. },
  713. delData(row){
  714. this.$confirm(`是否删除此条工作日历?`, '提示', {
  715. confirmButtonText: '确定',
  716. cancelButtonText: '取消',
  717. type: 'warning'
  718. }).then(() => {
  719. let inData={
  720. site:row.site.toString(),
  721. calendarId:row.calendarId,
  722. }
  723. delCalendar(inData).then(({data}) => {
  724. if (data.code == 200) {
  725. this.getData()
  726. this.$message({
  727. message: '操作成功',
  728. type: 'success',
  729. duration: 1500,
  730. onClose: () => {
  731. }
  732. })
  733. } else {
  734. this.$alert(data.msg, '错误', {
  735. confirmButtonText: '确定'
  736. })
  737. }
  738. })
  739. })
  740. },
  741. refreshModel(){
  742. this.getAll();
  743. let mainData={
  744. site:this.$store.state.user.site.toString(),
  745. calendarId:this.calendarSearchData.calendarId,
  746. calendarDesc:this.calendarSearchData.calendarDesc,
  747. }
  748. getCalendarData(mainData).then(({data}) => {
  749. let list=data.rows;
  750. if(list.length>0){
  751. for (let i = 0; i <list.length ; i++) {
  752. list[i].val0=this.calendarSearchData.datetype;
  753. list[i].val1=this.calendarSearchData.datetype;
  754. list[i].val2=this.calendarSearchData.datetype;
  755. list[i].val3=this.calendarSearchData.datetype;
  756. list[i].val4=this.calendarSearchData.datetype;
  757. list[i].val5=this.calendarSearchData.datetype;
  758. list[i].val6=this.calendarSearchData.datetype;
  759. list[i].val7=this.calendarSearchData.datetype;
  760. list[i].val8=this.calendarSearchData.datetype;
  761. }
  762. }
  763. this.dataList3 = list;
  764. })
  765. },
  766. getSelections(){
  767. },
  768. getSelectData () {
  769. this.selectList = [];
  770. let newData={
  771. value:'',
  772. label:'请选择',
  773. }
  774. this.selectList.push(newData)
  775. let inputData={
  776. site:this.$store.state.user.site.toString()
  777. };
  778. calendarDatetypeInfo(inputData).then(({data}) => {
  779. let list = data.rows
  780. this.calendarSearchData.datetype= list[0].datetype;
  781. for (let i = 0; i < list.length; i++) {
  782. let resultData = {
  783. value: list[i].datetype,
  784. label: list[i].datetype
  785. }
  786. this.selectList.push(resultData)
  787. }
  788. })
  789. },
  790. //获取日期
  791. GetDateStr(AddDayCount) {
  792. var dd = new Date();
  793. dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
  794. var y = dd.getFullYear();
  795. var m = (dd.getMonth()+1)<10?"0"+(dd.getMonth()+1):(dd.getMonth()+1);//获取当前月份的日期不足10补0
  796. var d = dd.getDate()<10?"0"+dd.getDate():dd.getDate();//获取当前几号不足10补0
  797. return y+"-"+m+"-"+d;
  798. },
  799. //获取区间所有时间并生成动态列
  800. getAll(){
  801. let begin=this.calendarSearchData.startDate;
  802. var dd = new Date(begin);
  803. dd.setDate(dd.getDate() + 8);//获取AddDayCount天后的日期
  804. var y = dd.getFullYear();
  805. var m = (dd.getMonth()+1)<10?"0"+(dd.getMonth()+1):(dd.getMonth()+1);//获取当前月份的日期不足10补0
  806. var d = dd.getDate()<10?"0"+dd.getDate():dd.getDate();//获取当前几号不足10补0
  807. let end=y+"-"+m+"-"+d;
  808. var startNum = parseInt(begin.replace(/-/g, ''), 10);
  809. var endNum = parseInt(end.replace(/-/g, ''), 10);
  810. if (startNum > endNum) {
  811. this.$alert('结束时间不能在开始时间之前!', '错误', {
  812. confirmButtonText: '确定'
  813. })
  814. return false;
  815. }
  816. if(this.DateDiff(begin, end)>9){
  817. this.$alert('时间不得相差10天!', '错误', {
  818. confirmButtonText: '确定'
  819. })
  820. return false;
  821. }
  822. this.timeArray = [];
  823. this.maintainColumnList2=[];
  824. let ab = begin.split("-");
  825. let ae = end.split("-");
  826. let db = new Date();
  827. db.setUTCFullYear(ab[0], ab[1]-1, ab[2]);
  828. let de = new Date();
  829. de.setUTCFullYear(ae[0], ae[1]-1, ae[2]);
  830. let unixDb=db.getTime();
  831. let unixDe=de.getTime();
  832. for(let k=unixDb;k<=unixDe;){
  833. this.timeArray.push(this.dateFormat(new Date(parseInt(k))));
  834. k=k+24*60*60*1000;
  835. }
  836. for (let i = 0; i <this.timeArray.length ; i++) {
  837. let property = this.timeArray[i];
  838. let val = "val"+i;
  839. this.maintainColumnList2.push(
  840. {
  841. columnProp:val,
  842. headerAlign:'center',
  843. align:'left',
  844. width:'100px',
  845. columnLabel:property,
  846. value:'',
  847. }
  848. );
  849. }
  850. },
  851. dateFormat(date){
  852. let s='';
  853. s+=date.getFullYear()+'-'; // 获取年份。
  854. s+=(date.getMonth()+1)+"-"; // 获取月份。
  855. s+= date.getDate(); // 获取日。
  856. return(s); // 返回日期。
  857. },
  858. //计算两个日期相差多少天
  859. DateDiff(sDate1, sDate2) {
  860. let aDate = sDate1.split("-");
  861. let oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]); //转换为yyyy-MM-dd格式
  862. aDate = sDate2.split("-");
  863. let oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]);
  864. let iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24);
  865. return iDays;
  866. },
  867. saveList() {
  868. let inData = {
  869. timeList: this.timeArray,
  870. batchCDVoList: this.dataListSelections
  871. }
  872. batchSaveCDData(inData).then(({data}) => {
  873. if (data && data.code == 200) {
  874. this.$message({
  875. message: '操作成功',
  876. type: 'success',
  877. duration: 1500,
  878. onClose: () => {
  879. }
  880. })
  881. } else {
  882. this.$alert(data.msg, '错误', {
  883. confirmButtonText: '确定'
  884. })
  885. }
  886. })
  887. },
  888. /*关闭modal*/
  889. closeDialog(){
  890. this.$emit('update:visible', false);
  891. },
  892. },
  893. created() {
  894. this.getData()
  895. }
  896. }
  897. </script>
  898. <style >
  899. .calendar .el-table .cell {
  900. height: 27px;
  901. }
  902. </style>