StoreCheckJob.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="计划名称">
  8. <a-input v-model="queryParam.planName" placeholder="请输入计划名称"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8" :sm="24">
  12. <a-form-item label="负责人">
  13. <a-input v-model="queryParam.keyword" placeholder="请输入负责人"/>
  14. </a-form-item>
  15. </a-col>
  16. <a-col :md="8" :sm="24">
  17. <a-form-item label="任务状态">
  18. <a-select
  19. v-model="queryParam.status"
  20. placeholder="请选择">
  21. <a-select-option
  22. v-for="(label,value) in statusMap"
  23. :key="value"
  24. :label="label"
  25. :value="parseInt(value)">{{ label }}
  26. </a-select-option>
  27. </a-select>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :md="8 || 24" :sm="24">
  31. <span class="table-page-search-submitButtons">
  32. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  33. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  34. </span>
  35. </a-col>
  36. </a-row>
  37. </a-form>
  38. </div>
  39. <!-- <div class="table-operator">
  40. <a-button v-if="$auth('check-jobs-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  41. <a-button style="margin-left: 8px" v-if="($auth('check-spot-jobs-export') || $auth('check-polling-jobs-export'))" type="primary" icon="download" @click="doExport">导出</a-button>
  42. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && ($auth('check-spot-jobs-finish') || $auth('check-polling-jobs-finish'))">
  43. <a-menu slot="overlay">
  44. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  45. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  46. </a-popconfirm>
  47. </a-menu>
  48. <a-button style="margin-left: 8px">
  49. 批量操作 <a-icon type="down" />
  50. </a-button>
  51. </a-dropdown>
  52. </div>-->
  53. <s-table
  54. ref="table"
  55. size="default"
  56. rowKey="id"
  57. :columns="columns"
  58. :data="loadData"
  59. :alert="options.alert"
  60. :rowSelection="options.rowSelection"
  61. showPagination="auto"
  62. >
  63. <span slot="action" slot-scope="record">
  64. <template>
  65. <a @click="handleView(record)">查看</a>
  66. <template v-if="record.status === DictCache.VALUE.CHECK_JOB_STATUS.NOT_EXECUTE">
  67. <a-divider type="vertical" />
  68. <a @click="handleFinish(record)">完成</a>
  69. </template>
  70. <template v-if="record.status != DictCache.VALUE.CHECK_JOB_STATUS.NOT_EXECUTE">
  71. <a-divider type="vertical" />
  72. <a @click="handleEdit(record)">盘点</a>
  73. </template>
  74. </template>
  75. </span>
  76. <span slot="status" slot-scope="text">
  77. <badge
  78. :status="DictCache.COLOR.JOB_STATUS[text]"
  79. :text="statusMap[text]" />
  80. </span>
  81. </s-table>
  82. <base-form :check-type="checkType" ref="baseModal" @ok="handleOk"/>
  83. <detail :check-type="checkType" ref="detailModal"/>
  84. </a-card>
  85. </template>
  86. <script>
  87. import { STable, Ellipsis } from '@/components'
  88. import BaseForm from './modules/BaseForm'
  89. import Detail from './modules/Detail'
  90. import { getCheckJobPage, deleteCheckJobs, fetchCheckJob, exportCheckJob, executeJob } from '@/api/store/storecheckjob'
  91. export default {
  92. name: 'CheckJobList',
  93. components: {
  94. STable,
  95. Ellipsis,
  96. BaseForm,
  97. Detail
  98. },
  99. props: {
  100. /**
  101. * 检查类型: 1-负责 2-巡检
  102. */
  103. checkType: {
  104. type: Number,
  105. default: 1
  106. },
  107. filter: {
  108. type: Number,
  109. default: -1
  110. }
  111. },
  112. data () {
  113. this.names = ['负责', '巡检']
  114. return {
  115. // 查询参数
  116. queryParam: {
  117. type: this.checkType,
  118. filter: this.filter
  119. },
  120. // 表头
  121. columns: [
  122. {
  123. title: '序号',
  124. dataIndex: 'index',
  125. customRender: (text, record, index) => {
  126. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  127. }
  128. },
  129. {
  130. title: '计划名称',
  131. dataIndex: 'planName'
  132. },
  133. {
  134. title: '仓库名称',
  135. dataIndex: 'storeName'
  136. },
  137. {
  138. title: '备件名称',
  139. dataIndex: 'spareName'
  140. },
  141. {
  142. title: '待盘数量',
  143. dataIndex: 'checkNum'
  144. },
  145. {
  146. title: '实际数量',
  147. dataIndex: 'realNum'
  148. },
  149. {
  150. title: '盘盈盘亏',
  151. dataIndex: 'profit',
  152. customRender: (text) => {
  153. if (text === 0) {
  154. return '正常'
  155. }
  156. if (text === 1) {
  157. return '盘亏'
  158. }
  159. if (text === 2) {
  160. return '盘盈'
  161. }
  162. }
  163. },
  164. {
  165. title: '说明',
  166. dataIndex: 'remark'
  167. },
  168. {
  169. title: '处理结果',
  170. dataIndex: 'feedback'
  171. },
  172. {
  173. title: '开始时间',
  174. dataIndex: 'startTime'
  175. },
  176. {
  177. title: '结束时间',
  178. dataIndex: 'endTime'
  179. },
  180. {
  181. title: '任务状态',
  182. dataIndex: 'status',
  183. scopedSlots: { customRender: 'status' }
  184. },
  185. {
  186. title: '操作',
  187. key: 'action',
  188. width: '200px',
  189. align: 'center',
  190. scopedSlots: { customRender: 'action' }
  191. }
  192. ],
  193. // 下拉框map
  194. statusMap: {},
  195. sbStatusMap: {},
  196. // 加载数据方法 必须为 Promise 对象
  197. loadData: parameter => {
  198. parameter = {
  199. ...parameter,
  200. ...this.queryParam,
  201. dataScope: {
  202. }
  203. }
  204. return getCheckJobPage(Object.assign(parameter, this.queryParam))
  205. .then(res => {
  206. return res.data
  207. })
  208. },
  209. selectedRowKeys: [],
  210. selectedRows: [],
  211. options: {
  212. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  213. rowSelection: {
  214. selectedRowKeys: this.selectedRowKeys,
  215. onChange: this.onSelectChange
  216. }
  217. },
  218. optionAlertShow: false
  219. }
  220. },
  221. created () {
  222. // 下拉框map
  223. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.STORE_CHECK_JOB_STATUS)
  224. this.sbStatusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  225. this.tableOption()
  226. },
  227. methods: {
  228. tableOption () {
  229. if (!this.optionAlertShow) {
  230. this.options = {
  231. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  232. rowSelection: {
  233. selectedRowKeys: this.selectedRowKeys,
  234. onChange: this.onSelectChange,
  235. getCheckboxProps: record => ({
  236. props: {
  237. disabled: false,
  238. name: record.id
  239. }
  240. })
  241. }
  242. }
  243. this.optionAlertShow = true
  244. } else {
  245. this.options = {
  246. alert: false,
  247. rowSelection: null
  248. }
  249. this.optionAlertShow = false
  250. }
  251. },
  252. batchDelete (id) {
  253. let ids = []
  254. if (this.BaseTool.String.isBlank(id)) {
  255. const length = this.selectedRows.length
  256. if (length === 0) {
  257. this.$message.info('请选择要删除的记录')
  258. return
  259. }
  260. ids = this.selectedRows.map(item => item.id)
  261. } else {
  262. ids = [id]
  263. }
  264. deleteCheckJobs(ids).then(res => {
  265. this.$message.info('删除成功')
  266. this.handleOk()
  267. this.$refs.table.clearSelected()
  268. })
  269. },
  270. handleEdit (record) {
  271. const modal = this.$refs.baseModal
  272. modal.base(record)
  273. },
  274. handleFinish (record) {
  275. fetchCheckJob({ id: record.id }).then(res => {
  276. const modal = this.$refs.baseModal
  277. modal.base(res.data)
  278. })
  279. },
  280. handleExecute (record) {
  281. executeJob({ id: record.id }).then(res => {
  282. this.handleOk()
  283. })
  284. },
  285. handleView (record) {
  286. fetchCheckJob({ id: record.id }).then(res => {
  287. const modal = this.$refs.detailModal
  288. modal.base(res.data)
  289. })
  290. },
  291. handleOk () {
  292. this.$refs.table.refresh()
  293. },
  294. onSelectChange (selectedRowKeys, selectedRows) {
  295. this.selectedRowKeys = selectedRowKeys
  296. this.selectedRows = selectedRows
  297. },
  298. resetSearchForm () {
  299. this.queryParam = {
  300. }
  301. this.$refs.table.refresh(true)
  302. },
  303. doExport () {
  304. const parameter = {
  305. ...this.queryParam
  306. }
  307. exportCheckJob(parameter).then(file => {
  308. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  309. })
  310. }
  311. }
  312. }
  313. </script>