eac320c1959366d331128aa71f030cee0f0d29b8.svn-base 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  5. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  6. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  7. <el-select v-model="table.getdataListParm.parammaps.times" filterable placeholder="班次" class="filter-item" style="width: 120px;" clearable>
  8. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  9. </el-select>
  10. <el-select v-model="table.getdataListParm.parammaps.eqclass" placeholder="设备类别" class="filter-item" style="width: 120px;" clearable>
  11. <el-option v-for="item in equipmentCategoryList" :key="item.id" :label="item.name" :value="item.name" />
  12. </el-select>
  13. <el-input ref="eqcode" v-model="table.getdataListParm.parammaps.eqcode" class="filter-item" placeholder="设备编号" style="width: 120px;" />
  14. <el-input ref="driver" v-model="table.getdataListParm.parammaps.driver" class="filter-item" placeholder="驾驶员" style="width: 120px;" />
  15. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  16. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  17. </div>
  18. <div class="operation">
  19. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" style="float: left;margin-right:10px;" @click="handleCreate">分配</el-button>
  20. <el-button v-if="isRoleEdit" icon="el-icon-delete" class="danger" style="float: left;margin-right:10px;" @click="handleDelete">删除</el-button>
  21. <el-button class="export" icon="el-icon-upload2" style="float: right;margin-right: 10px;" @click="handleExport">导出</el-button>
  22. </div>
  23. <div class="table">
  24. <el-table
  25. :key="table.tableKey"
  26. v-loading="table.listLoading"
  27. element-loading-text="给我一点时间"
  28. :data="table.list"
  29. border
  30. fit
  31. highlight-current-row
  32. style="width: 100%;"
  33. :row-style="rowStyle"
  34. :cell-style="cellStyle"
  35. class="elTable table-fixed"
  36. @selection-change="handleSelectionChange"
  37. >
  38. <el-table-column type="selection" align="center" width="50" />
  39. <el-table-column label="序号" align="center" type="index" width="50px">
  40. <template slot-scope="scope">
  41. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="生效日期" min-width="150px" align="center">
  45. <template slot-scope="scope">
  46. <span>{{ scope.row.operatetime }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="班次" min-width="150px" align="center">
  50. <template slot-scope="scope">
  51. <span>{{ scope.row.times }}</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="设备类别" min-width="90px" align="center">
  55. <template slot-scope="scope">
  56. <span>{{ scope.row.eqclass }}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="设备编号" min-width="100px" align="center">
  60. <template slot-scope="scope">
  61. <span>{{ scope.row.eqcode }}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="驾驶员" min-width="90px" align="center">
  65. <template slot-scope="scope">
  66. <span>{{ scope.row.driver }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="分配人" min-width="90px" align="center">
  70. <template slot-scope="scope">
  71. <span>{{ scope.row.emp }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="操作" align="center" width="50" class-name="small-padding fixed-width" fixed="right">
  75. <template slot-scope="{row}">
  76. <el-button v-if="isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  81. </div>
  82. <!-- 新增/编辑 -->
  83. <el-dialog :fullscreen="dialogFull" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  84. <template slot="title">
  85. <div class="avue-crud__dialog__header">
  86. <span class="el-dialog__title">
  87. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  88. {{ textMap[create.dialogStatus] }}
  89. </span>
  90. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  91. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  92. <svg-icon v-else icon-class="fullscreen" />
  93. </div>
  94. </div>
  95. </template>
  96. <div class="app-add">
  97. <el-tabs v-model="create.activeName" @tab-click="handleClick">
  98. <el-tab-pane label="TMR设备" name="first">
  99. <div class="TMR">
  100. <div class="table">
  101. <el-table
  102. :key="create.tableKey"
  103. v-loading="create.listLoading"
  104. element-loading-text="给我一点时间"
  105. :data="create.list"
  106. border
  107. fit
  108. highlight-current-row
  109. style="width: 100%;margin-bottom: 50px;"
  110. :row-style="rowStyle"
  111. :cell-style="cellStyle"
  112. class="elTable table-fixed"
  113. >
  114. <el-table-column label="班次" min-width="150px" align="center">
  115. <template slot-scope="scope">
  116. <span>{{ scope.row.timesstr }}</span>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="设备类别" min-width="90px" align="center">
  120. <template slot-scope="scope">
  121. <span>{{ scope.row.eqclass }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="设备编号" min-width="100px" align="center">
  125. <template slot-scope="scope">
  126. <span>{{ scope.row.eqcode }}</span>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="驾驶员" min-width="90px" align="center">
  130. <template slot-scope="scope">
  131. <el-select v-model="scope.row.driverid" filterable placeholder="驾驶员" class="filter-item" style="width: 100%;padding: 0 10px;" @change="(value)=> {changeDriver(value, scope.row)}">
  132. <el-option v-for="item in driverList" :key="item.id" :label="item.drivername" :value="item.id" />
  133. </el-select>
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="生效日期" min-width="90px" align="center">
  137. <template slot-scope="scope">
  138. <el-date-picker v-model="scope.row.operatetime" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="生效日期" :clearable="false" class="filter-item operatetime" style="width: 100%;" @focus="focusOperatetime(scope.row)" @change="changeOperatetime(scope.row)" />
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. </div>
  143. <div slot="footer" class="dialog-footer" style="bottom: 20px;">
  144. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  145. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="save" :disabled="isokDisable" @click="createData()">确认</el-button>
  146. </div>
  147. </div>
  148. </el-tab-pane>
  149. <el-tab-pane label="铲车" name="second">
  150. <div class="forklift">
  151. <div class="table">
  152. <el-table
  153. :key="create.tableKey2"
  154. v-loading="create.listLoading2"
  155. element-loading-text="给我一点时间"
  156. :data="create.list2"
  157. border
  158. fit
  159. highlight-current-row
  160. style="width: 100%;margin-bottom: 50px;"
  161. :row-style="rowStyle"
  162. :cell-style="cellStyle"
  163. class="elTable table-fixed"
  164. >
  165. <el-table-column label="班次" min-width="150px" align="center">
  166. <template slot-scope="scope">
  167. <span>{{ scope.row.timesstr }}</span>
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="设备类别" min-width="90px" align="center">
  171. <template slot-scope="scope">
  172. <span>{{ scope.row.eqclass }}</span>
  173. </template>
  174. </el-table-column>
  175. <el-table-column label="设备编号" min-width="100px" align="center">
  176. <template slot-scope="scope">
  177. <span>{{ scope.row.eqcode }}</span>
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="驾驶员" min-width="90px" align="center">
  181. <template slot-scope="scope">
  182. <el-select v-model="scope.row.driverid" filterable placeholder="驾驶员" class="filter-item" style="width: 100%;padding: 0 10px;" @change="(value)=> {changeDriver(value, scope.row)}">
  183. <el-option v-for="item in driverList" :key="item.id" :label="item.drivername" :value="item.id" />
  184. </el-select>
  185. </template>
  186. </el-table-column>
  187. <el-table-column label="生效日期" min-width="90px" align="center">
  188. <template slot-scope="scope">
  189. <el-date-picker v-model="scope.row.operatetime" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" :clearable="false" placeholder="生效日期" class="filter-item operatetime" style="width: 100%;" @focus="focusOperatetime2(scope.row)" @change="changeOperatetime2(scope.row)" />
  190. </template>
  191. </el-table-column>
  192. </el-table>
  193. </div>
  194. <div slot="footer" class="dialog-footer" style="bottom: 20px;">
  195. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  196. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="save" :disabled="isokDisable" @click="createData2()">确认</el-button>
  197. </div>
  198. </div>
  199. </el-tab-pane>
  200. </el-tabs>
  201. </div>
  202. </el-dialog>
  203. </div>
  204. </template>
  205. <script>
  206. import { GetDataByName, PostDataByName, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  207. import Cookies from 'js-cookie'
  208. import { parseTime, json2excel } from '@/utils/index.js'
  209. import Pagination from '@/components/Pagination'
  210. import { MessageBox } from 'element-ui'
  211. var createList = []
  212. export default {
  213. name: 'DutyRecord',
  214. components: { Pagination },
  215. data() {
  216. return {
  217. dialogFull: false,
  218. isRoleEdit: [],
  219. requestParams: [
  220. { name: 'getSysoptEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid'), 'inforname': 'times' }},
  221. { name: 'getDriverListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }}
  222. ],
  223. equipmentCategoryList: [{ id: '1', name: 'TMR设备' }, { id: '2', name: '铲车' }], // 设备类别
  224. frequencyList: [], // 班次
  225. driverList: [], // 驾驶员
  226. table: {
  227. getdataListParm: {
  228. name: 'getDutyrecordList',
  229. page: 1,
  230. offset: 1,
  231. pagecount: parseInt(Cookies.get('pageCount')),
  232. returntype: 'Map',
  233. parammaps: {
  234. pastureid: Cookies.get('pastureid'),
  235. barid: '',
  236. startTime: '',
  237. stopTime: '',
  238. inputDatetime: '',
  239. times: '',
  240. eqclass: ''
  241. }
  242. },
  243. tableKey: 0,
  244. list: [],
  245. total: 0,
  246. listLoading: true,
  247. temp: {}
  248. },
  249. // 新增/编辑
  250. create: {
  251. dialogFormVisible: false,
  252. dialogStatus: '',
  253. temp: { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d} {h}:{m}'), emp: Cookies.get('employename'), barid: '', barname: '', remain: '', times: '' },
  254. rules: {},
  255. tableKey: 0,
  256. list: [],
  257. createList: [],
  258. total: 0,
  259. listLoading: true,
  260. getdataListParm: {
  261. name: 'geEqListByDplan',
  262. page: 1,
  263. offset: 1,
  264. pagecount: '',
  265. returntype: 'Map',
  266. parammaps: {
  267. pastureid: Cookies.get('pastureid')
  268. }
  269. },
  270. tableKey2: 0,
  271. list2: [],
  272. createList2: [],
  273. total2: 0,
  274. listLoading2: true,
  275. getdataListParm2: {
  276. name: 'geEqListByDplanCC',
  277. page: 1,
  278. offset: 1,
  279. pagecount: '',
  280. returntype: 'Map',
  281. parammaps: {
  282. pastureid: Cookies.get('pastureid')
  283. }
  284. },
  285. activeName: 'first'
  286. },
  287. textMap: {
  288. create: '分配'
  289. },
  290. requestParam: {},
  291. download: {
  292. getdataListParm: {
  293. name: 'getDutyrecordList',
  294. page: 1,
  295. offset: 1,
  296. pagecount: 0,
  297. returntype: 'Map',
  298. parammaps: {
  299. pastureid: Cookies.get('pastureid'),
  300. barid: '',
  301. startTime: '',
  302. stopTime: '',
  303. inputDatetime: '',
  304. times: '',
  305. eqclass: ''
  306. }
  307. },
  308. list: []
  309. },
  310. isokDisable: false,
  311. selectList: [],
  312. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  313. cellStyle: { padding: 0 + 'px' }
  314. }
  315. },
  316. created() {
  317. this.getList()
  318. this.getDownList()
  319. this.getButtons()
  320. },
  321. methods: {
  322. getButtons() {
  323. const Edit = 'DutyRecord'
  324. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  325. this.isRoleEdit = isRoleEdit
  326. },
  327. getDownList() {
  328. GetDataByNames(this.requestParams).then(response => {
  329. if (response.data.getSysoptEnable.list !== null) {
  330. for (let i = 1; i <= response.data.getSysoptEnable.list[0].inforvalue; i++) {
  331. const obj = {}
  332. obj.id = String(i)
  333. if (i == 1) { obj.name = '第一班' } else if (i == 2) { obj.name = '第二班' } else if (i == 3) { obj.name = '第三班' } else if (i == 4) { obj.name = '第四班' }
  334. this.frequencyList.push(obj)
  335. }
  336. } else {
  337. this.frequencyList = []
  338. }
  339. this.driverList = response.data.getDriverListEnable.list
  340. })
  341. },
  342. handleBefore() {
  343. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  344. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  345. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  346. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  347. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  348. this.$forceUpdate()
  349. }
  350. },
  351. handleNext() {
  352. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  353. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  354. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  355. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  356. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  357. this.$forceUpdate()
  358. }
  359. },
  360. getList() {
  361. this.table.listLoading = true
  362. GetDataByName(this.table.getdataListParm).then(response => {
  363. console.log('table数据', response.data.list)
  364. if (response.data.list !== null) {
  365. this.table.list = response.data.list
  366. this.table.pageNum = response.data.pageNum
  367. this.table.pageSize = response.data.pageSize
  368. this.table.total = response.data.total
  369. } else {
  370. this.table.list = []
  371. }
  372. setTimeout(() => {
  373. this.table.listLoading = false
  374. }, 100)
  375. })
  376. },
  377. handleSearch() {
  378. console.log('点击了查询')
  379. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  380. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  381. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  382. } else {
  383. this.table.getdataListParm.parammaps.inputDatetime = ''
  384. this.table.getdataListParm.parammaps.startTime = ''
  385. this.table.getdataListParm.parammaps.stopTime = ''
  386. }
  387. this.table.getdataListParm.offset = 1
  388. this.getList()
  389. },
  390. handleRefresh() {
  391. console.log('点击了重置')
  392. this.table.getdataListParm.parammaps.times = ''
  393. this.table.getdataListParm.parammaps.eqclass = ''
  394. this.table.getdataListParm.parammaps.eqcode = ''
  395. this.table.getdataListParm.parammaps.driver = ''
  396. this.table.getdataListParm.parammaps.startTime = ''
  397. this.table.getdataListParm.parammaps.stopTime = ''
  398. this.table.getdataListParm.parammaps.inputDatetime = ''
  399. this.table.getdataListParm.offset = 1
  400. this.getList()
  401. },
  402. // 新增
  403. handleCreate() {
  404. console.log('点击了分配')
  405. this.create.dialogStatus = 'create'
  406. this.dialogFull = false
  407. this.create.dialogFormVisible = true
  408. this.getDialogList()
  409. },
  410. handleClick() {
  411. if (this.create.activeName == 'first') {
  412. this.getDialogList()
  413. } else if (this.create.activeName == 'second') {
  414. this.getDialogList2()
  415. }
  416. },
  417. getDialogList() {
  418. GetDataByName(this.create.getdataListParm).then(response => {
  419. console.log('table数据1', response.data.list)
  420. if (response.data.list !== null) {
  421. for (let i = 0; i < response.data.list.length; i++) {
  422. if (response.data.list[i].driver == undefined || response.data.list[i].driverid == undefined) {
  423. this.$set(response.data.list[i], 'driver', '')
  424. this.$set(response.data.list[i], 'driverid', '')
  425. }
  426. this.$set(response.data.list[i], 'sort', 'create' + i)
  427. }
  428. this.create.list = response.data.list
  429. } else {
  430. this.create.list = []
  431. }
  432. setTimeout(() => {
  433. this.create.listLoading = false
  434. }, 100)
  435. })
  436. },
  437. getDialogList2() {
  438. GetDataByName(this.create.getdataListParm2).then(response => {
  439. console.log('table2数据', response.data.list)
  440. if (response.data.list !== null) {
  441. for (let i = 0; i < response.data.list.length; i++) {
  442. if (response.data.list[i].driver == undefined || response.data.list[i].driverid == undefined) {
  443. this.$set(response.data.list[i], 'driver', '')
  444. this.$set(response.data.list[i], 'driverid', '')
  445. }
  446. this.$set(response.data.list[i], 'sort', 'create2' + i)
  447. }
  448. this.create.list2 = response.data.list
  449. } else {
  450. this.create.list2 = []
  451. }
  452. setTimeout(() => {
  453. this.create.listLoading2 = false
  454. }, 100)
  455. })
  456. },
  457. changeDriver(item, row) {
  458. row.driver = this.driverList.find(obj => obj.id == item).drivername
  459. },
  460. focusOperatetime(row) {
  461. console.log(row)
  462. GetDataByName(this.create.getdataListParm).then(response => {
  463. if (response.data.list !== null) {
  464. for (let i = 0; i < response.data.list.length; i++) {
  465. if (response.data.list[i].driver == undefined || response.data.list[i].driverid == undefined) {
  466. this.$set(response.data.list[i], 'driver', '')
  467. this.$set(response.data.list[i], 'driverid', '')
  468. }
  469. this.$set(response.data.list[i], 'sort', 'create' + i)
  470. }
  471. this.create.createList = [...response.data.list]
  472. } else {
  473. this.create.createList = []
  474. }
  475. })
  476. },
  477. changeOperatetime(row) {
  478. console.log(this.create.createList)
  479. for (let i = 0; i < this.create.createList.length; i++) {
  480. if (row.sort == this.create.createList[i].sort) {
  481. if (new Date(row.operatetime) < new Date(this.create.createList[i].operatetime)) {
  482. row.operatetime = this.create.createList[i].operatetime
  483. this.$message({ type: 'error', message: '生效日期不可小于上次日期', duration: 2000 })
  484. }
  485. }
  486. }
  487. },
  488. focusOperatetime2(row) {
  489. console.log(row)
  490. GetDataByName(this.create.getdataListParm2).then(response => {
  491. if (response.data.list !== null) {
  492. for (let i = 0; i < response.data.list.length; i++) {
  493. if (response.data.list[i].driver == undefined || response.data.list[i].driverid == undefined) {
  494. this.$set(response.data.list[i], 'driver', '')
  495. this.$set(response.data.list[i], 'driverid', '')
  496. }
  497. this.$set(response.data.list[i], 'sort', 'create2' + i)
  498. }
  499. this.create.createList2 = [...response.data.list]
  500. } else {
  501. this.create.createList2 = []
  502. }
  503. })
  504. },
  505. changeOperatetime2(row) {
  506. console.log(this.create.createList2)
  507. for (let i = 0; i < this.create.createList2.length; i++) {
  508. if (row.sort == this.create.createList2[i].sort) {
  509. if (new Date(row.operatetime) < new Date(this.create.createList2[i].operatetime)) {
  510. row.operatetime = this.create.createList2[i].operatetime
  511. this.$message({ type: 'error', message: '生效日期不可小于上次日期', duration: 2000 })
  512. }
  513. }
  514. }
  515. },
  516. createData() {
  517. console.log('点击了新增保存', this.create.list)
  518. this.isokDisable = true
  519. setTimeout(() => {
  520. this.isokDisable = false
  521. }, 1000)
  522. for (var i = 0; i < this.create.list.length; i++) {
  523. if (this.create.list[i].driverid == '') {
  524. this.create.list.splice(i, 1)
  525. i = 0
  526. }
  527. }
  528. console.log('点击了新增保存', this.create.list)
  529. this.requestParam.common = { 'returnmap': '0' }
  530. this.requestParam.data = []
  531. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.create.list }}
  532. this.requestParam.data[0].children = []
  533. this.requestParam.data[0].children[0] = { 'name': 'insertDutyrecord', 'type': 'e', 'parammaps': {
  534. pastureid: '@insertSpotList.pastureid',
  535. eqid: '@insertSpotList.eqid',
  536. eqclass: '@insertSpotList.eqclass',
  537. eqcode: '@insertSpotList.eqcode',
  538. driver: '@insertSpotList.driver',
  539. driverid: '@insertSpotList.driverid',
  540. times: '@insertSpotList.times',
  541. operatetime: '@insertSpotList.operatetime',
  542. emp: Cookies.get('employename')
  543. }}
  544. ExecDataByConfig(this.requestParam).then(response => {
  545. console.log('分配TMR设备保存发送参数', this.requestParam)
  546. if (response.msg === 'fail') {
  547. const dutyrecordUniq = new RegExp("key 'dutyrecord-uniq'")
  548. if (dutyrecordUniq.test(response.data)) {
  549. this.$message({ type: 'error', message: '当前日期已分配驾驶员不可重复分配', duration: 2000 })
  550. } else {
  551. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  552. }
  553. } else {
  554. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  555. this.create.dialogFormVisible = false
  556. this.getList()
  557. }
  558. })
  559. },
  560. createData2() {
  561. console.log('分配铲车', this.create.list2)
  562. this.isokDisable = true
  563. setTimeout(() => {
  564. this.isokDisable = false
  565. }, 1000)
  566. for (var i = 0; i < this.create.list2.length; i++) {
  567. if (this.create.lis2t[i].driverid == '') {
  568. this.create.list2.splice(i, 1)
  569. i = 0
  570. }
  571. }
  572. console.log('点击了新增保存', this.create.list)
  573. this.requestParam.common = { 'returnmap': '0' }
  574. this.requestParam.data = []
  575. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.create.list2 }}
  576. this.requestParam.data[0].children = []
  577. this.requestParam.data[0].children[0] = { 'name': 'insertDutyrecord', 'type': 'e', 'parammaps': {
  578. pastureid: '@insertSpotList.pastureid',
  579. eqid: '@insertSpotList.eqid',
  580. eqclass: '@insertSpotList.eqclass',
  581. eqcode: '@insertSpotList.eqcode',
  582. driver: '@insertSpotList.driver',
  583. driverid: '@insertSpotList.driverid',
  584. times: '@insertSpotList.times',
  585. operatetime: '@insertSpotList.operatetime',
  586. emp: Cookies.get('employename')
  587. }}
  588. ExecDataByConfig(this.requestParam).then(response => {
  589. console.log('分配TMR设备保存发送参数', this.requestParam)
  590. if (response.msg === 'fail') {
  591. const dutyrecordUniq = new RegExp("key 'dutyrecord-uniq'")
  592. if (dutyrecordUniq.test(response.data)) {
  593. this.$message({ type: 'error', message: '当前日期已分配驾驶员不可重复分配', duration: 2000 })
  594. } else {
  595. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  596. }
  597. } else {
  598. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  599. this.create.dialogFormVisible = false
  600. this.getList()
  601. }
  602. })
  603. },
  604. // 删除
  605. handleRowDelete(row) {
  606. console.log('点击了行内删除')
  607. this.selectList = []
  608. MessageBox.confirm('是否确认删除此信息?', {
  609. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  610. }).then(() => {
  611. this.selectList = []
  612. this.requestParam.name = 'deleteDutyrecord'
  613. this.requestParam.parammaps = {}
  614. this.requestParam.parammaps.pastureid = row.pastureid
  615. this.requestParam.parammaps.id = row.id
  616. PostDataByName(this.requestParam).then(response => {
  617. if (response.msg === 'fail') {
  618. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  619. } else {
  620. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  621. this.getList()
  622. }
  623. })
  624. }).catch(() => {
  625. this.$message({ type: 'info', message: '已取消删除' })
  626. })
  627. },
  628. handleSelectionChange(val) {
  629. console.log('勾选数据', val)
  630. this.selectList = val
  631. },
  632. handleDelete() {
  633. console.log('点击了删除')
  634. if (this.selectList.length == 0) {
  635. this.$message({ type: 'error', message: '请选择值班记录', duration: 2000 })
  636. } else {
  637. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  638. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  639. }).then(() => {
  640. console.log(this.selectList)
  641. this.requestParam.common = { 'returnmap': '0' }
  642. this.requestParam.data = []
  643. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  644. this.requestParam.data[0].children = []
  645. this.requestParam.data[0].children[0] = { 'name': 'deleteDutyrecord', 'type': 'e', 'parammaps': {
  646. id: '@insertSpotList.id',
  647. pastureid: '@insertSpotList.pastureid'
  648. }}
  649. ExecDataByConfig(this.requestParam).then(response => {
  650. console.log('删除保存发送参数', this.requestParam)
  651. if (response.msg === 'fail') {
  652. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  653. } else {
  654. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  655. this.getList()
  656. }
  657. })
  658. })
  659. }
  660. },
  661. // 导出
  662. handleExport() {
  663. console.log('点击了导出')
  664. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  665. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  666. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  667. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  668. } else {
  669. this.download.getdataListParm.parammaps.inputDatetime = ''
  670. this.download.getdataListParm.parammaps.startTime = ''
  671. this.download.getdataListParm.parammaps.stopTime = ''
  672. }
  673. GetDataByName(this.download.getdataListParm).then(response => {
  674. if (response.data.list !== null) {
  675. this.download.list = response.data.list
  676. } else {
  677. this.download.list = []
  678. }
  679. var excelDatas = [
  680. {
  681. tHeader: ['生效日期', '班次', '设备类别', '设备编号', '驾驶员', '分配人'],
  682. filterVal: ['operatetime', 'times', 'eqclass', 'eqcode', 'driver', 'emp'],
  683. tableDatas: this.download.list,
  684. sheetName: 'Sheet1'
  685. }
  686. ]
  687. json2excel(excelDatas, '值班记录', true, 'xlsx')
  688. })
  689. }
  690. }
  691. }
  692. </script>
  693. <style lang="scss" scoped>
  694. .search{padding-top:10px;clear: both;}
  695. .table{margin-top:10px;}
  696. /deep/ .operatetime {margin-right: 0;}
  697. </style>