9bb31a42d787c73f467bcfaea53ae7172e39a796.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button v-if="isRoleEdit" class="success" style="float: left;margin-right:10px;" @click="handleCreate">分配</el-button>
  5. <el-button v-if="isRoleEdit" class="danger" style="float: left;margin-right:10px;" @click="handleDelete">删除</el-button>
  6. <el-button v-if="isRoleEdit" class="import" style="float: right;" @click="handleImport">导入</el-button>
  7. <el-button class="export" style="float: right;margin-right: 10px;" @click="handleExport">导出</el-button>
  8. </div>
  9. <div class="search">
  10. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  11. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  12. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  13. <el-select v-model="table.getdataListParm.parammaps.times" filterable placeholder="班次" class="filter-item" style="width: 120px;" clearable>
  14. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  15. </el-select>
  16. <el-select v-model="table.getdataListParm.parammaps.eqclass" placeholder="设备类别" class="filter-item" style="width: 120px;" clearable>
  17. <el-option v-for="item in equipmentCategoryList" :key="item.id" :label="item.name" :value="item.name" />
  18. </el-select>
  19. <el-input ref="eqcode" v-model="table.getdataListParm.parammaps.eqcode" class="filter-item" placeholder="设备编号" style="width: 120px;" />
  20. <el-input ref="driver" v-model="table.getdataListParm.parammaps.driver" class="filter-item" placeholder="驾驶员" style="width: 120px;" />
  21. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  22. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  23. </div>
  24. <div class="table">
  25. <el-table
  26. :key="table.tableKey"
  27. v-loading="table.listLoading"
  28. element-loading-text="给我一点时间"
  29. :data="table.list"
  30. border
  31. fit
  32. highlight-current-row
  33. style="width: 100%;"
  34. :row-style="rowStyle"
  35. :cell-style="cellStyle"
  36. class="elTable table-fixed"
  37. @selection-change="handleSelectionChange"
  38. >
  39. <el-table-column type="selection" align="center" width="50" />
  40. <el-table-column label="序号" align="center" type="index" width="50px">
  41. <template slot-scope="scope">
  42. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="生效日期" min-width="150px" align="center">
  46. <template slot-scope="scope">
  47. <span>{{ scope.row.operatetime }}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="班次" min-width="150px" align="center">
  51. <template slot-scope="scope">
  52. <span>{{ scope.row.times }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="设备类别" min-width="90px" align="center">
  56. <template slot-scope="scope">
  57. <span>{{ scope.row.eqclass }}</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="设备编号" min-width="100px" align="center">
  61. <template slot-scope="scope">
  62. <span>{{ scope.row.eqcode }}</span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="驾驶员" min-width="90px" align="center">
  66. <template slot-scope="scope">
  67. <span>{{ scope.row.driver }}</span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="分配人" min-width="90px" align="center">
  71. <template slot-scope="scope">
  72. <span>{{ scope.row.emp }}</span>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  76. <template slot-scope="{row}">
  77. <el-button v-if="isRoleEdit" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  82. </div>
  83. <!-- 新增/编辑 -->
  84. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  85. <div class="app-add">
  86. <div class="table">
  87. <el-table
  88. :key="create.tableKey"
  89. v-loading="create.listLoading"
  90. element-loading-text="给我一点时间"
  91. :data="create.list"
  92. border
  93. fit
  94. highlight-current-row
  95. style="width: 100%;margin-bottom: 50px;"
  96. :row-style="rowStyle"
  97. :cell-style="cellStyle"
  98. class="elTable table-fixed"
  99. >
  100. <el-table-column label="班次" min-width="150px" align="center">
  101. <template slot-scope="scope">
  102. <span>{{ scope.row.times }}</span>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="设备类别" min-width="90px" align="center">
  106. <template slot-scope="scope">
  107. <span>{{ scope.row.eqclass }}</span>
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="设备编号" min-width="100px" align="center">
  111. <template slot-scope="scope">
  112. <span>{{ scope.row.eqcode }}</span>
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="驾驶员" min-width="90px" align="center">
  116. <template slot-scope="scope">
  117. <el-select v-model="scope.row.driverid" filterable placeholder="驾驶员" class="filter-item" style="width: 100%;padding: 0 10px;" @change="(value)=> {changeDriver(value, scope.row)}">
  118. <el-option v-for="item in driverList" :key="item.id" :label="item.drivername" :value="item.id" />
  119. </el-select>
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. </div>
  124. <div slot="footer" class="dialog-footer">
  125. <el-button class="cancel" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  126. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  127. </div>
  128. </div>
  129. </el-dialog>
  130. </div>
  131. </template>
  132. <script>
  133. import { GetDataByName, PostDataByName, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  134. import Cookies from 'js-cookie'
  135. import { parseTime } from '@/utils/index.js'
  136. import Pagination from '@/components/Pagination'
  137. import { MessageBox } from 'element-ui'
  138. export default {
  139. name: 'DutyRecord',
  140. components: { Pagination },
  141. data() {
  142. return {
  143. isRoleEdit: [],
  144. requestParams: [
  145. { name: 'getSysoptEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid'), 'inforname': 'times' }},
  146. { name: 'getDriverListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }}
  147. ],
  148. equipmentCategoryList: [{ id: '1', name: 'TMR设备' }, { id: '2', name: '铲车' }], // 设备类别
  149. frequencyList: [], // 班次
  150. driverList: [], // 驾驶员
  151. table: {
  152. getdataListParm: {
  153. name: 'getDutyrecordList',
  154. page: 1,
  155. offset: 1,
  156. pagecount: 10,
  157. returntype: 'Map',
  158. parammaps: {
  159. pastureid: Cookies.get('pastureid'),
  160. barid: '',
  161. startTime: '',
  162. stopTime: '',
  163. inputDatetime: '',
  164. times: '',
  165. eqclass: ''
  166. }
  167. },
  168. tableKey: 0,
  169. list: [],
  170. total: 0,
  171. listLoading: true,
  172. temp: {}
  173. },
  174. // 新增/编辑
  175. create: {
  176. dialogFormVisible: false,
  177. dialogStatus: '',
  178. temp: { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d} {h}:{m}'), emp: Cookies.get('employename'), barid: '', barname: '', remain: '', times: '' },
  179. rules: {},
  180. tableKey: 0,
  181. list: [],
  182. total: 0,
  183. listLoading: true,
  184. getdataListParm: {
  185. name: 'geEqListByDplan',
  186. page: 1,
  187. offset: 1,
  188. pagecount: 10,
  189. returntype: 'Map',
  190. parammaps: {
  191. pastureid: Cookies.get('pastureid')
  192. }
  193. }
  194. },
  195. textMap: {
  196. create: '分配'
  197. },
  198. requestParam: {},
  199. isokDisable: false,
  200. selectList: [],
  201. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  202. cellStyle: { padding: 0 + 'px' }
  203. }
  204. },
  205. created() {
  206. this.getList()
  207. this.getDownList()
  208. this.getButtons()
  209. },
  210. methods: {
  211. getButtons() {
  212. const Edit = 'DutyRecord'
  213. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  214. this.isRoleEdit = isRoleEdit
  215. },
  216. getDownList() {
  217. GetDataByNames(this.requestParams).then(response => {
  218. if (response.data.getSysoptEnable.list !== null) {
  219. for (let i = 1; i <= response.data.getSysoptEnable.list[0].inforvalue; i++) {
  220. const obj = {}
  221. obj.id = String(i)
  222. if (i == 1) { obj.name = '第一班' } else if (i == 2) { obj.name = '第二班' } else if (i == 3) { obj.name = '第三班' } else if (i == 4) { obj.name = '第四班' }
  223. this.frequencyList.push(obj)
  224. }
  225. } else {
  226. this.frequencyList = []
  227. }
  228. this.driverList = response.data.getDriverListEnable.list
  229. })
  230. },
  231. handleBefore() {
  232. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  233. var start = this.table.getdataListParm.parammaps.inputDatetime[0] - 3600 * 1000 * 24
  234. var stop = this.table.getdataListParm.parammaps.inputDatetime[1] - 3600 * 1000 * 24
  235. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  236. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  237. this.$forceUpdate()
  238. }
  239. },
  240. handleNext() {
  241. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  242. var start = this.table.getdataListParm.parammaps.inputDatetime[0] + 3600 * 1000 * 24
  243. var stop = this.table.getdataListParm.parammaps.inputDatetime[1] + 3600 * 1000 * 24
  244. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  245. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  246. this.$forceUpdate()
  247. }
  248. },
  249. getList() {
  250. this.table.listLoading = true
  251. GetDataByName(this.table.getdataListParm).then(response => {
  252. console.log('table数据', response.data.list)
  253. if (response.data.list !== null) {
  254. this.table.list = response.data.list
  255. this.table.pageNum = response.data.pageNum
  256. this.table.pageSize = response.data.pageSize
  257. this.table.total = response.data.total
  258. } else {
  259. this.table.list = []
  260. }
  261. setTimeout(() => {
  262. this.table.listLoading = false
  263. }, 100)
  264. })
  265. },
  266. handleSearch() {
  267. console.log('点击了查询')
  268. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  269. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  270. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  271. } else {
  272. this.table.getdataListParm.parammaps.inputDatetime = ''
  273. this.table.getdataListParm.parammaps.startTime = ''
  274. this.table.getdataListParm.parammaps.stopTime = ''
  275. }
  276. this.table.getdataListParm.offset = 1
  277. this.getList()
  278. },
  279. handleRefresh() {
  280. console.log('点击了重置')
  281. this.table.getdataListParm.parammaps.times = ''
  282. this.table.getdataListParm.parammaps.eqclass = ''
  283. this.table.getdataListParm.parammaps.eqcode = ''
  284. this.table.getdataListParm.parammaps.driver = ''
  285. this.table.getdataListParm.parammaps.startTime = ''
  286. this.table.getdataListParm.parammaps.stopTime = ''
  287. this.table.getdataListParm.parammaps.inputDatetime = ''
  288. this.table.getdataListParm.offset = 1
  289. this.getList()
  290. },
  291. // 新增
  292. handleCreate() {
  293. console.log('点击了分配')
  294. this.create.dialogStatus = 'create'
  295. this.create.dialogFormVisible = true
  296. this.getDialogList()
  297. },
  298. getDialogList() {
  299. GetDataByName(this.create.getdataListParm).then(response => {
  300. console.log('table数据', response.data.list)
  301. if (response.data.list !== null) {
  302. for (let i = 0; i < response.data.list.length; i++) {
  303. if (response.data.list[i].driver == undefined || response.data.list[i].driverid == undefined) {
  304. this.$set(response.data.list[i], 'driver', '')
  305. this.$set(response.data.list[i], 'driverid', '')
  306. }
  307. }
  308. this.create.list = response.data.list
  309. } else {
  310. this.create.list = []
  311. }
  312. setTimeout(() => {
  313. this.create.listLoading = false
  314. }, 100)
  315. })
  316. },
  317. changeDriver(item, row) {
  318. row.driver = this.driverList.find(obj => obj.id == item).drivername
  319. },
  320. createData() {
  321. console.log('点击了新增保存', this.create.list)
  322. this.isokDisable = true
  323. setTimeout(() => {
  324. this.isokDisable = false
  325. }, 1000)
  326. for (let i = 0; i < this.create.list.length; i++) {
  327. if (this.create.list[i].driverid == '') {
  328. this.create.list.splice(i, 1)
  329. }
  330. }
  331. console.log('点击了新增保存', this.create.list)
  332. this.requestParam.common = { 'returnmap': '0' }
  333. this.requestParam.data = []
  334. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.create.list }}
  335. this.requestParam.data[0].children = []
  336. this.requestParam.data[0].children[0] = { 'name': 'insertDutyrecord', 'type': 'e', 'parammaps': {
  337. pastureid: '@insertSpotList.pastureid',
  338. eqid: '@insertSpotList.eqid',
  339. eqclass: '@insertSpotList.eqclass',
  340. eqcode: '@insertSpotList.eqcode',
  341. driver: '@insertSpotList.driver',
  342. driverid: '@insertSpotList.driverid',
  343. times: '@insertSpotList.times',
  344. operatedate: parseTime(new Date(), '{y}-{m}-{d}'),
  345. emp: Cookies.get('employename')
  346. }}
  347. ExecDataByConfig(this.requestParam).then(response => {
  348. console.log('分配保存发送参数', this.requestParam)
  349. if (response.msg === 'fail') {
  350. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  351. } else {
  352. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  353. this.create.dialogFormVisible = false
  354. this.getList()
  355. }
  356. })
  357. },
  358. // 删除
  359. handleRowDelete(row) {
  360. console.log('点击了行内删除')
  361. this.selectList = []
  362. MessageBox.confirm('是否确认删除此信息?', {
  363. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  364. }).then(() => {
  365. this.selectList = []
  366. this.requestParam.name = 'deleteDutyrecord'
  367. this.requestParam.parammaps = {}
  368. this.requestParam.parammaps.pastureid = row.pastureid
  369. this.requestParam.parammaps.id = row.id
  370. PostDataByName(this.requestParam).then(response => {
  371. if (response.msg === 'fail') {
  372. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  373. } else {
  374. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  375. this.getList()
  376. }
  377. })
  378. }).catch(() => {
  379. this.$message({ type: 'info', message: '已取消删除' })
  380. })
  381. },
  382. handleSelectionChange(val) {
  383. console.log('勾选数据', val)
  384. this.selectList = val
  385. },
  386. handleDelete() {
  387. console.log('点击了删除')
  388. if (this.selectList.length == 0) {
  389. this.$message({ type: 'error', message: '请选择值班记录', duration: 2000 })
  390. } else {
  391. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  392. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  393. }).then(() => {
  394. console.log(this.selectList)
  395. this.requestParam.common = { 'returnmap': '0' }
  396. this.requestParam.data = []
  397. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  398. this.requestParam.data[0].children = []
  399. this.requestParam.data[0].children[0] = { 'name': 'deleteDutyrecord', 'type': 'e', 'parammaps': {
  400. id: '@insertSpotList.id',
  401. pastureid: '@insertSpotList.pastureid'
  402. }}
  403. ExecDataByConfig(this.requestParam).then(response => {
  404. console.log('删除保存发送参数', this.requestParam)
  405. if (response.msg === 'fail') {
  406. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  407. } else {
  408. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  409. this.getList()
  410. }
  411. })
  412. })
  413. }
  414. },
  415. // 导出
  416. handleExport() {
  417. console.log('点击了导出')
  418. },
  419. // 导入
  420. handleImport() {
  421. console.log('点击了导入')
  422. }
  423. }
  424. }
  425. </script>
  426. <style lang="scss" scoped>
  427. .search{padding-top:10px;clear: both;}
  428. .table{margin-top:10px;}
  429. </style>