TaskList.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. getCheckboxProps: getTaskkboxProps,
  46. }"
  47. @change="handleTableChange"
  48. >
  49. <template slot="taskType" slot-scope="value">
  50. {{ value === 1 ? '全盘' : '抽盘' }}
  51. </template>
  52. <template slot="taskStatus" slot-scope="value">
  53. {{ formateTaskStatus(value) }}
  54. </template>
  55. <span slot="action" slot-scope="text, record">
  56. <a @click="addTask('detail', record)">查看</a>
  57. <a-divider type="vertical" />
  58. <a :disabled="record.taskStatus !== 1" @click="addTask('edit', record)">编辑</a>
  59. <a-divider type="vertical" />
  60. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  61. <a :disabled="record.taskStatus !== 1 && record.taskStatus !== 4">删除</a>
  62. </a-popconfirm>
  63. </span>
  64. </a-table>
  65. </a-card>
  66. </a-col>
  67. <stock-modal
  68. :spinnerList="spinnerList"
  69. :deoptData="deoptData"
  70. :stockVisible.sync="stockVisible"
  71. :title="title"
  72. :rules="rules"
  73. :taskId="taskId"
  74. :openType="openType"
  75. ref="stockF"
  76. ></stock-modal>
  77. </a-row>
  78. </template>
  79. <script>
  80. // import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  81. import FilterForm from './components/FilterForm.vue'
  82. import table from './utils/table'
  83. import StockModal from './components/stockModal.vue'
  84. import { getAction, postAction } from '@/api/manage'
  85. import { newTableMixin } from '@/mixins/newTableMixin'
  86. export default {
  87. components: { FilterForm, StockModal },
  88. mixins: [newTableMixin],
  89. data() {
  90. return {
  91. description: '盘点任务列表',
  92. // 表头
  93. scroll: { x: 1500 },
  94. // 权限按钮集合
  95. btnEnableList: [1, 1, 1],
  96. queryParam: {
  97. taskStatus: '',
  98. number: '',
  99. depotId: '',
  100. createBy: '',
  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. created() {
  144. this.getList()
  145. this.getSpinnerList(), this.getDepotList()
  146. },
  147. methods: {
  148. addTask(type, data) {
  149. this.taskId = ''
  150. this.openType = type
  151. this.title = type === 'add' ? '新增盘点任务' : type === 'edit' ? '编辑盘点任务' : '查看盘点任务'
  152. if (type !== 'add') {
  153. this.getDetailList(data.id)
  154. }
  155. this.stockVisible = true
  156. },
  157. getList(type) {
  158. if (type === 'search') this.ipagination.current = 1 // 重新加载数据时,重置当前页为第一页
  159. if (type === 'reset') {
  160. for (let i in this.queryParam) {
  161. this.$set(this.queryParam, i, null)
  162. }
  163. }
  164. const url = this.url.list + '?currentPage=' + this.ipagination.current + '&pageSize=' + this.ipagination.pageSize
  165. this.loading = true
  166. const params = { ...this.queryParam }
  167. postAction(url, params).then((res) => {
  168. this.dataSource = res.data.rows
  169. this.ipagination.total = Number(res.data.total)
  170. this.loading = false
  171. })
  172. },
  173. getDetailList(id) {
  174. this.taskId = id
  175. },
  176. getSpinnerList() {
  177. getAction(this.url.spinnerList).then((res) => {
  178. this.spinnerList = res.data || []
  179. })
  180. },
  181. getDepotList() {
  182. getAction(this.url.depotList).then((res) => {
  183. this.deoptData = res.data.map((item) => {
  184. return {
  185. label: item.depotName,
  186. value: item.id,
  187. }
  188. })
  189. })
  190. },
  191. handleDelete(id) {
  192. const ids = id || this.selectedRowKeys
  193. const url = this.url.delete + ids
  194. getAction(url)
  195. .then((res) => {
  196. this.$message.success('删除成功')
  197. this.getList()
  198. })
  199. .catch((err) => {
  200. this.$message.error('删除失败')
  201. })
  202. },
  203. cancelTask() {
  204. const ids = this.selectedRowKeys
  205. const url = this.url.cancel + 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. },
  216. }
  217. </script>
  218. <style></style>