95cf0eacae2d5d6d90deba5530146b62204f8be2.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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.label" :value="item.label" />
  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: 'getDictByName', offset: 0, pagecount: 0, params: ['TMR设备类型'] },
  146. { name: 'getSysoptEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid'), 'inforname': 'times' }},
  147. { name: 'getDriverListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }}
  148. ],
  149. equipmentCategoryList: [], // 设备类别
  150. frequencyList: [], // 班次
  151. driverList: [], // 驾驶员
  152. table: {
  153. getdataListParm: {
  154. name: 'getDutyrecordList',
  155. page: 1,
  156. offset: 1,
  157. pagecount: 10,
  158. returntype: 'Map',
  159. parammaps: {
  160. pastureid: Cookies.get('pastureid'),
  161. barid: '',
  162. startTime: '',
  163. stopTime: '',
  164. inputDatetime: '',
  165. times: '',
  166. eqclass: ''
  167. }
  168. },
  169. tableKey: 0,
  170. list: [],
  171. total: 0,
  172. listLoading: true,
  173. temp: {}
  174. },
  175. // 新增/编辑
  176. create: {
  177. dialogFormVisible: false,
  178. dialogStatus: '',
  179. temp: { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d} {h}:{m}'), emp: Cookies.get('employename'), barid: '', barname: '', remain: '', times: '' },
  180. rules: {},
  181. tableKey: 0,
  182. list: [],
  183. total: 0,
  184. listLoading: true,
  185. getdataListParm: {
  186. name: 'geEqListByDplan',
  187. page: 1,
  188. offset: 1,
  189. pagecount: 10,
  190. returntype: 'Map',
  191. parammaps: {
  192. pastureid: Cookies.get('pastureid')
  193. }
  194. }
  195. },
  196. textMap: {
  197. create: '分配'
  198. },
  199. requestParam: {},
  200. isokDisable: false,
  201. selectList: [],
  202. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  203. cellStyle: { padding: 0 + 'px' }
  204. }
  205. },
  206. created() {
  207. this.getList()
  208. this.getDownList()
  209. this.getButtons()
  210. },
  211. methods: {
  212. getButtons() {
  213. const Edit = 'DutyRecord'
  214. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  215. this.isRoleEdit = isRoleEdit
  216. },
  217. getDownList() {
  218. GetDataByNames(this.requestParams).then(response => {
  219. this.equipmentCategoryList = response.data.getDictByName.list
  220. if (response.data.getSysoptEnable.list !== null) {
  221. for (let i = 1; i <= response.data.getSysoptEnable.list[0].inforvalue; i++) {
  222. const obj = {}
  223. obj.id = String(i)
  224. if (i == 1) { obj.name = '第一班' } else if (i == 2) { obj.name = '第二班' } else if (i == 3) { obj.name = '第三班' } else if (i == 4) { obj.name = '第四班' }
  225. this.frequencyList.push(obj)
  226. }
  227. } else {
  228. this.frequencyList = []
  229. }
  230. this.driverList = response.data.getDriverListEnable.list
  231. })
  232. },
  233. handleBefore() {
  234. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  235. var start = this.table.getdataListParm.parammaps.inputDatetime[0] - 3600 * 1000 * 24
  236. var stop = this.table.getdataListParm.parammaps.inputDatetime[1] - 3600 * 1000 * 24
  237. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  238. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  239. this.$forceUpdate()
  240. }
  241. },
  242. handleNext() {
  243. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  244. var start = this.table.getdataListParm.parammaps.inputDatetime[0] + 3600 * 1000 * 24
  245. var stop = this.table.getdataListParm.parammaps.inputDatetime[1] + 3600 * 1000 * 24
  246. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  247. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  248. this.$forceUpdate()
  249. }
  250. },
  251. getList() {
  252. this.table.listLoading = true
  253. GetDataByName(this.table.getdataListParm).then(response => {
  254. console.log('table数据', response.data.list)
  255. if (response.data.list !== null) {
  256. this.table.list = response.data.list
  257. this.table.pageNum = response.data.pageNum
  258. this.table.pageSize = response.data.pageSize
  259. this.table.total = response.data.total
  260. } else {
  261. this.table.list = []
  262. }
  263. setTimeout(() => {
  264. this.table.listLoading = false
  265. }, 100)
  266. })
  267. },
  268. handleSearch() {
  269. console.log('点击了查询')
  270. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  271. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  272. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  273. } else {
  274. this.table.getdataListParm.parammaps.inputDatetime = ''
  275. this.table.getdataListParm.parammaps.startTime = ''
  276. this.table.getdataListParm.parammaps.stopTime = ''
  277. }
  278. this.table.getdataListParm.offset = 1
  279. this.getList()
  280. },
  281. handleRefresh() {
  282. console.log('点击了重置')
  283. this.table.getdataListParm.parammaps.times = ''
  284. this.table.getdataListParm.parammaps.eqclass = ''
  285. this.table.getdataListParm.parammaps.eqcode = ''
  286. this.table.getdataListParm.parammaps.driver = ''
  287. this.table.getdataListParm.parammaps.startTime = ''
  288. this.table.getdataListParm.parammaps.stopTime = ''
  289. this.table.getdataListParm.parammaps.inputDatetime = ''
  290. this.table.getdataListParm.offset = 1
  291. this.getList()
  292. },
  293. // 新增
  294. handleCreate() {
  295. console.log('点击了分配')
  296. this.create.dialogStatus = 'create'
  297. this.create.dialogFormVisible = true
  298. this.getDialogList()
  299. },
  300. getDialogList() {
  301. GetDataByName(this.create.getdataListParm).then(response => {
  302. console.log('table数据', response.data.list)
  303. if (response.data.list !== null) {
  304. for (let i = 0; i < response.data.list.length; i++) {
  305. if (response.data.list[i].driver == undefined || response.data.list[i].driverid == undefined) {
  306. this.$set(response.data.list[i], 'driver', '')
  307. this.$set(response.data.list[i], 'driverid', '')
  308. }
  309. }
  310. this.create.list = response.data.list
  311. } else {
  312. this.create.list = []
  313. }
  314. setTimeout(() => {
  315. this.create.listLoading = false
  316. }, 100)
  317. })
  318. },
  319. changeDriver(item, row) {
  320. row.driver = this.driverList.find(obj => obj.id == item).drivername
  321. },
  322. createData() {
  323. console.log('点击了新增保存')
  324. this.isokDisable = true
  325. setTimeout(() => {
  326. this.isokDisable = false
  327. }, 1000)
  328. this.requestParam.common = { 'returnmap': '0' }
  329. this.requestParam.data = []
  330. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.create.list }}
  331. this.requestParam.data[0].children = []
  332. this.requestParam.data[0].children[0] = { 'name': 'insertDutyrecord', 'type': 'e', 'parammaps': {
  333. pastureid: '@insertSpotList.pastureid',
  334. eqid: '@insertSpotList.eqid',
  335. eqclass: '@insertSpotList.eqclass',
  336. eqcode: '@insertSpotList.eqcode',
  337. driver: '@insertSpotList.driver',
  338. driverid: '@insertSpotList.driverid',
  339. times: '@insertSpotList.times',
  340. operatedate: parseTime(new Date(), '{y}-{m}-{d}'),
  341. emp: Cookies.get('employename')
  342. }}
  343. ExecDataByConfig(this.requestParam).then(response => {
  344. console.log('分配保存发送参数', this.requestParam)
  345. if (response.msg === 'fail') {
  346. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  347. } else {
  348. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  349. this.create.dialogFormVisible = false
  350. this.getList()
  351. }
  352. })
  353. },
  354. // 删除
  355. handleRowDelete(row) {
  356. console.log('点击了行内删除')
  357. this.selectList = []
  358. MessageBox.confirm('是否确认删除此信息?', {
  359. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  360. }).then(() => {
  361. this.selectList = []
  362. this.requestParam.name = 'deleteDutyrecord'
  363. this.requestParam.parammaps = {}
  364. this.requestParam.parammaps.pastureid = row.pastureid
  365. this.requestParam.parammaps.id = row.id
  366. PostDataByName(this.requestParam).then(response => {
  367. if (response.msg === 'fail') {
  368. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  369. } else {
  370. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  371. this.getList()
  372. }
  373. })
  374. }).catch(() => {
  375. this.$message({ type: 'info', message: '已取消删除' })
  376. })
  377. },
  378. handleSelectionChange(val) {
  379. console.log('勾选数据', val)
  380. this.selectList = val
  381. },
  382. handleDelete() {
  383. console.log('点击了删除')
  384. if (this.selectList.length == 0) {
  385. this.$message({ type: 'error', message: '请选择值班记录', duration: 2000 })
  386. } else {
  387. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  388. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  389. }).then(() => {
  390. console.log(this.selectList)
  391. this.requestParam.common = { 'returnmap': '0' }
  392. this.requestParam.data = []
  393. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  394. this.requestParam.data[0].children = []
  395. this.requestParam.data[0].children[0] = { 'name': 'deleteDutyrecord', 'type': 'e', 'parammaps': {
  396. id: '@insertSpotList.id',
  397. pastureid: '@insertSpotList.pastureid'
  398. }}
  399. ExecDataByConfig(this.requestParam).then(response => {
  400. console.log('删除保存发送参数', this.requestParam)
  401. if (response.msg === 'fail') {
  402. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  403. } else {
  404. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  405. this.getList()
  406. }
  407. })
  408. })
  409. }
  410. },
  411. // 导出
  412. handleExport() {
  413. console.log('点击了导出')
  414. },
  415. // 导入
  416. handleImport() {
  417. console.log('点击了导入')
  418. }
  419. }
  420. }
  421. </script>
  422. <style lang="scss" scoped>
  423. .search{padding-top:10px;clear: both;}
  424. .table{margin-top:10px;}
  425. </style>