3387f714e5b35c7553e835f395241705ffaf2f9e.svn-base 16 KB

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