TaskList.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <a-row :gutter="24">
  3. <a-col :md="24">
  4. <a-card :bordered="false" :style="cardStyle">
  5. <!-- 查询区域 -->
  6. <filter-form
  7. @search="onSearch"
  8. @reset="onReset"
  9. :queryParam="queryParam"
  10. :spinnerList="spinnerList"
  11. :deoptData="deoptData"
  12. ></filter-form>
  13. <div style="margin-bottom: 6px">
  14. <a-button type="primary" icon="plus" @click="addTask('add')">新增盘点任务</a-button>
  15. <a-popconfirm
  16. :disabled="!selectedRowKeys.length"
  17. style="margin: 0 6px"
  18. title="确定取消选中的盘点任务吗?"
  19. @confirm="() => cancelTask()"
  20. >
  21. <a-button :disabled="!selectedRowKeys.length">取消盘点</a-button>
  22. </a-popconfirm>
  23. <a-popconfirm
  24. :disabled="!selectedRowKeys.length"
  25. title="确定删除选中的盘点任务吗?"
  26. @confirm="() => handleDelete()"
  27. >
  28. <a-button :disabled="!selectedRowKeys.length">批量删除</a-button>
  29. </a-popconfirm>
  30. <!-- <a-button style="margin-left: 6px">导出任务</a-button> -->
  31. </div>
  32. <a-table
  33. ref="table"
  34. size="middle"
  35. bordered
  36. rowKey="id"
  37. :columns="columns"
  38. :dataSource="dataSource"
  39. :pagination="ipagination"
  40. :scroll="scroll"
  41. :loading="loading"
  42. :rowSelection="{
  43. selectedRowKeys: selectedRowKeys,
  44. onChange: onSelectChange,
  45. }"
  46. @change="handleTableChange"
  47. >
  48. <template slot="taskType" slot-scope="value">
  49. {{ value === 1 ? '全盘' : '抽盘' }}
  50. </template>
  51. <template slot="taskStatus" slot-scope="value">
  52. {{ formateTaskStatus(value) }}
  53. </template>
  54. <span slot="action" slot-scope="text, record">
  55. <a @click="addTask('detail', record)">查看</a>
  56. <a-divider type="vertical" />
  57. <a :disabled="record.taskStatus !== 1" @click="addTask('edit', record)">编辑</a>
  58. <a-divider type="vertical" />
  59. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  60. <a :disabled="record.taskStatus !== 1 && record.taskStatus !== 4">删除</a>
  61. </a-popconfirm>
  62. </span>
  63. </a-table>
  64. </a-card>
  65. </a-col>
  66. <stock-modal
  67. :spinnerList="spinnerList"
  68. :deoptData="deoptData"
  69. :stockVisible.sync="stockVisible"
  70. :title="title"
  71. :rules="rules"
  72. :taskId="taskId"
  73. :openType="openType"
  74. ref="stockF"
  75. ></stock-modal>
  76. </a-row>
  77. </template>
  78. <script>
  79. import FilterForm from './components/FilterForm.vue'
  80. import table from './utils/table'
  81. import StockModal from './components/stockModal.vue'
  82. import { getAction, postAction } from '@/api/manage'
  83. import { newTableMixin } from '@/mixins/newTableMixin'
  84. import { mixinDevice } from '@/utils/mixin.js'
  85. export default {
  86. components: { FilterForm, StockModal },
  87. mixins: [newTableMixin,mixinDevice],
  88. data() {
  89. return {
  90. description: '盘点任务列表',
  91. cardStyle: '',
  92. // 表头
  93. scroll: { x: 1500 },
  94. // 权限按钮集合
  95. btnEnableList: [1, 1, 1],
  96. queryParam: {
  97. taskStatus: undefined,
  98. number: '',
  99. depotId: undefined,
  100. createBy: undefined,
  101. },
  102. // stockTable: {
  103. // loading: false,
  104. // dataSource: [],
  105. // columns: table.taskColumns,
  106. // },
  107. columns: table.taskColumns,
  108. dataSource: [],
  109. loading: false,
  110. rules: {
  111. taskType: { rules: [{ required: true, message: '请选择盘点类型' }] },
  112. depotId: { rules: [{ required: true, message: '请选择盘点仓库' }] },
  113. taskName: { rules: [{ required: true, message: '请输入盘点任务名称' }] },
  114. },
  115. // rules: {
  116. // number: { rules: [{ required: true, message: '请输入盘点编号' }] },
  117. // },
  118. url: {
  119. list: '/stocktaking/list',
  120. add: '/stocktaking/add',
  121. detailList: '/stocktaking/detail',
  122. spinnerList: '/stocktaking/creatorSpinnerList',
  123. depotList: '/depot/findDepotByCurrentUser',
  124. detailByItemList: '/stocktaking/detailByItemList',
  125. delete: '/stocktaking/taskDelete/',
  126. cancel: '/stocktaking/taskCancel/',
  127. },
  128. stockVisible: false,
  129. title: '',
  130. spinnerList: [],
  131. deoptData: [],
  132. taskId: '',
  133. openType: 'add',
  134. }
  135. },
  136. watch: {
  137. stockVisible(val) {
  138. if (!val) {
  139. this.getList()
  140. }
  141. },
  142. },
  143. computed: {
  144. isDel() {
  145. return this.selectionRows.filter((item) => item.taskStatus !== 1 && item.taskStatus !== 4).length > 0
  146. ? true
  147. : false
  148. },
  149. isStock() {
  150. return this.selectionRows.filter((item) => item.taskStatus !== 1 && item.taskStatus !== 2).length > 0
  151. ? true
  152. : false
  153. },
  154. },
  155. created() {
  156. if (this.isDesktop()) {
  157. this.cardStyle = 'min-height:' + (document.documentElement.clientHeight - 100) + 'px'
  158. }
  159. this.getList()
  160. this.getSpinnerList(), this.getDepotList()
  161. },
  162. methods: {
  163. addTask(type, data) {
  164. this.taskId = ''
  165. this.openType = type
  166. this.title = type === 'add' ? '新增盘点任务' : type === 'edit' ? '编辑盘点任务' : '查看盘点任务'
  167. if (type !== 'add') {
  168. this.getDetailList(data.id)
  169. }
  170. this.stockVisible = true
  171. },
  172. getList(type) {
  173. if (type === 'search') this.ipagination.current = 1 // 重新加载数据时,重置当前页为第一页
  174. if (type === 'reset') {
  175. for (let i in this.queryParam) {
  176. this.$set(this.queryParam, i, null)
  177. }
  178. }
  179. const url = this.url.list + '?currentPage=' + this.ipagination.current + '&pageSize=' + this.ipagination.pageSize
  180. this.loading = true
  181. const params = { ...this.queryParam }
  182. postAction(url, params).then((res) => {
  183. this.dataSource = res.data.rows
  184. this.ipagination.total = Number(res.data.total)
  185. this.loading = false
  186. })
  187. },
  188. getDetailList(id) {
  189. this.taskId = id
  190. },
  191. getSpinnerList() {
  192. getAction(this.url.spinnerList).then((res) => {
  193. this.spinnerList = res.data || []
  194. })
  195. },
  196. getDepotList() {
  197. getAction(this.url.depotList).then((res) => {
  198. this.deoptData = res.data.map((item) => {
  199. return {
  200. label: item.depotName,
  201. value: item.id,
  202. }
  203. })
  204. })
  205. },
  206. handleDelete(id) {
  207. if (this.isDel) return this.$message.error('只能删除未开始或已取消的盘点任务,请重新选择!')
  208. const ids = id || this.selectedRowKeys
  209. const url = this.url.delete + ids
  210. getAction(url)
  211. .then((res) => {
  212. this.$message.success('删除成功')
  213. this.getList()
  214. })
  215. .catch((err) => {
  216. this.$message.error('删除失败')
  217. })
  218. },
  219. cancelTask() {
  220. if (this.isStock) return this.$message.error('只能取消未开始或进行中的盘点任务,请重新选择!')
  221. const ids = this.selectedRowKeys
  222. const url = this.url.cancel + ids
  223. getAction(url)
  224. .then((res) => {
  225. this.$message.success('取消成功')
  226. this.getList()
  227. })
  228. .catch((err) => {
  229. this.$message.error('取消失败')
  230. })
  231. },
  232. },
  233. }
  234. </script>
  235. <style scoped>
  236. @import '~@assets/less/common.less';
  237. </style>