CheckList.vue 7.0 KB

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