TaskList.vue 6.1 KB

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