TaskList.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <a-row :gutter="24">
  3. <a-col :md="24">
  4. <a-card :bordered="false">
  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 { JeecgListMixin } from '@/mixins/JeecgListMixin'
  80. import FilterForm from './components/FilterForm.vue'
  81. import table from './utils/table'
  82. import StockModal from './components/stockModal.vue'
  83. import { getAction, postAction } from '@/api/manage'
  84. import { newTableMixin } from '@/mixins/newTableMixin'
  85. export default {
  86. components: { FilterForm, StockModal },
  87. mixins: [newTableMixin],
  88. data() {
  89. return {
  90. description: '盘点任务列表',
  91. // 表头
  92. scroll: { x: 1500 },
  93. // 权限按钮集合
  94. btnEnableList: [1, 1, 1],
  95. queryParam: {
  96. taskStatus: undefined,
  97. number: '',
  98. depotId: undefined,
  99. createBy: undefined,
  100. },
  101. // stockTable: {
  102. // loading: false,
  103. // dataSource: [],
  104. // columns: table.taskColumns,
  105. // },
  106. columns: table.taskColumns,
  107. dataSource: [],
  108. loading: false,
  109. rules: {
  110. taskType: { rules: [{ required: true, message: '请选择盘点类型' }] },
  111. depotId: { rules: [{ required: true, message: '请选择盘点仓库' }] },
  112. taskName: { rules: [{ required: true, message: '请输入盘点任务名称' }] },
  113. },
  114. // rules: {
  115. // number: { rules: [{ required: true, message: '请输入盘点编号' }] },
  116. // },
  117. url: {
  118. list: '/stocktaking/list',
  119. add: '/stocktaking/add',
  120. detailList: '/stocktaking/detail',
  121. spinnerList: '/stocktaking/creatorSpinnerList',
  122. depotList: '/depot/findDepotByCurrentUser',
  123. detailByItemList: '/stocktaking/detailByItemList',
  124. delete: '/stocktaking/taskDelete/',
  125. cancel: '/stocktaking/taskCancel/',
  126. },
  127. stockVisible: false,
  128. title: '',
  129. spinnerList: [],
  130. deoptData: [],
  131. taskId: '',
  132. openType: 'add',
  133. }
  134. },
  135. watch: {
  136. stockVisible(val) {
  137. if (!val) {
  138. this.getList()
  139. }
  140. },
  141. },
  142. computed: {
  143. isDel() {
  144. return this.selectionRows.filter((item) => item.taskStatus !== 1 && item.taskStatus !== 4).length > 0
  145. ? true
  146. : false
  147. },
  148. isStock() {
  149. return this.selectionRows.filter((item) => item.taskStatus !== 1 && item.taskStatus !== 2).length > 0
  150. ? true
  151. : false
  152. },
  153. },
  154. created() {
  155. this.getList()
  156. this.getSpinnerList(), this.getDepotList()
  157. },
  158. methods: {
  159. addTask(type, data) {
  160. this.taskId = ''
  161. this.openType = type
  162. this.title = type === 'add' ? '新增盘点任务' : type === 'edit' ? '编辑盘点任务' : '查看盘点任务'
  163. if (type !== 'add') {
  164. this.getDetailList(data.id)
  165. }
  166. this.stockVisible = true
  167. },
  168. getList(type) {
  169. if (type === 'search') this.ipagination.current = 1 // 重新加载数据时,重置当前页为第一页
  170. if (type === 'reset') {
  171. for (let i in this.queryParam) {
  172. this.$set(this.queryParam, i, null)
  173. }
  174. }
  175. const url = this.url.list + '?currentPage=' + this.ipagination.current + '&pageSize=' + this.ipagination.pageSize
  176. this.loading = true
  177. const params = { ...this.queryParam }
  178. postAction(url, params).then((res) => {
  179. this.dataSource = res.data.rows
  180. this.ipagination.total = Number(res.data.total)
  181. this.loading = false
  182. })
  183. },
  184. getDetailList(id) {
  185. this.taskId = id
  186. },
  187. getSpinnerList() {
  188. getAction(this.url.spinnerList).then((res) => {
  189. this.spinnerList = res.data || []
  190. })
  191. },
  192. getDepotList() {
  193. getAction(this.url.depotList).then((res) => {
  194. this.deoptData = res.data.map((item) => {
  195. return {
  196. label: item.depotName,
  197. value: item.id,
  198. }
  199. })
  200. })
  201. },
  202. handleDelete(id) {
  203. if (this.isDel) return this.$message.error('只能删除未开始或已取消的盘点任务,请重新选择!')
  204. const ids = id || this.selectedRowKeys
  205. const url = this.url.delete + ids
  206. getAction(url)
  207. .then((res) => {
  208. this.$message.success('删除成功')
  209. this.getList()
  210. })
  211. .catch((err) => {
  212. this.$message.error('删除失败')
  213. })
  214. },
  215. cancelTask() {
  216. if (this.isStock) return this.$message.error('只能取消未开始或进行中的盘点任务,请重新选择!')
  217. const ids = this.selectedRowKeys
  218. const url = this.url.cancel + ids
  219. getAction(url)
  220. .then((res) => {
  221. this.$message.success('取消成功')
  222. this.getList()
  223. })
  224. .catch((err) => {
  225. this.$message.error('取消失败')
  226. })
  227. },
  228. },
  229. }
  230. </script>
  231. <style></style>