c5189ecc1224c3d3880acc8256d9e1045c1f12b3.svn-base 31 KB

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