CheckList.vue 6.5 KB

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