CheckList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <a-row :gutter="24">
  3. <a-col :md="24">
  4. <a-card :bordered="false" :style="cardStyle">
  5. <!-- 查询区域 -->
  6. <div class="table-page-search-wrapper">
  7. <a-form layout="inline" @keyup.enter.native="searchQuery">
  8. <a-row :gutter="24">
  9. <a-col :md="6" :sm="24">
  10. <a-form-item label="盘点状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
  11. <a-select placeholder="请选择盘点状态" showSearch :options="taskStatusList" v-model="queryParam.taskStatus">
  12. </a-select>
  13. </a-form-item>
  14. </a-col>
  15. <a-col :md="6" :sm="24">
  16. <a-form-item label="盘点单号" :labelCol="labelCol" :wrapperCol="wrapperCol">
  17. <a-input placeholder="请输入任务编号、名称" v-model="queryParam.number"></a-input>
  18. </a-form-item>
  19. </a-col>
  20. <a-col :md="6" :sm="24">
  21. <a-form-item label="盘点仓库" :labelCol="labelCol" :wrapperCol="wrapperCol">
  22. <a-select placeholder="请选择盘点仓库" showSearch :options="deoptData" v-model="queryParam.depotId">
  23. </a-select>
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="6" :sm="24">
  27. <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
  28. <a-button type="primary" @click="searchQuery">查询</a-button>
  29. <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
  30. <a @click="handleToggleSearch" style="margin-left: 8px">
  31. {{ toggleSearchStatus ? '收起' : '展开' }}
  32. <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
  33. </a>
  34. </span>
  35. </a-col>
  36. <template v-if="toggleSearchStatus">
  37. <a-col :md="6" :sm="24">
  38. <a-form-item label="创建人" :labelCol="labelCol" :wrapperCol="wrapperCol">
  39. <a-select placeholder="请选择创建人" showSearch :options="spinnerList" v-model="queryParam.createBy">
  40. </a-select>
  41. </a-form-item>
  42. </a-col>
  43. </template>
  44. </a-row>
  45. </a-form>
  46. </div>
  47. <div class="table-operator" style="margin-top: 5px">
  48. <a-button :disabled="!selectedRowKeys.length" type="primary" @click="onStartTask">开始盘点</a-button>
  49. </div>
  50. <a-table
  51. ref="table"
  52. size="middle"
  53. bordered
  54. rowKey="id"
  55. :columns="columns"
  56. :dataSource="dataSource"
  57. :pagination="ipagination"
  58. :scroll="scroll"
  59. :loading="loading"
  60. :rowSelection="{
  61. selectedRowKeys: selectedRowKeys,
  62. onChange: onSelectChange,
  63. getCheckboxProps: getCheckboxProps,
  64. }"
  65. @change="handleTableChange"
  66. >
  67. <template slot="taskType" slot-scope="value">
  68. {{ value === 1 ? '全盘' : '抽盘' }}
  69. </template>
  70. <template slot="taskStatus" slot-scope="value">
  71. {{ formateTaskStatus(value) }}
  72. </template>
  73. <span slot="action" slot-scope="text, record">
  74. <a @click="addTask('detail', record)">查看</a>
  75. <a-divider type="vertical" />
  76. <a :disabled="record.taskStatus > 3" @click="addTask('edit', record)">编辑</a>
  77. </span>
  78. </a-table>
  79. </a-card>
  80. </a-col>
  81. <check-modal
  82. :spinnerList="spinnerList"
  83. :deoptData="deoptData"
  84. :stockVisible.sync="stockVisible"
  85. :title="title"
  86. :rules="rules"
  87. :taskId="taskId"
  88. :openType="openType"
  89. ref="stockF"
  90. ></check-modal>
  91. </a-row>
  92. </template>
  93. <script>
  94. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  95. import { getAction, postAction } from '@/api/manage'
  96. import CheckModal from './components/checkModal.vue'
  97. export default {
  98. components: { CheckModal },
  99. mixins: [JeecgListMixin],
  100. data() {
  101. return {
  102. labelCol: {
  103. span: 4,
  104. },
  105. wrapperCol: {
  106. span: 19,
  107. offset: 1,
  108. },
  109. taskStatusList: [
  110. { value: 0, label: '未审核' },
  111. { value: 1, label: '已审核' },
  112. { value: 2, label: '进行中' },
  113. { value: 3, label: '已完成' },
  114. { value: 4, label: '已取消' },
  115. { value: 5, label: '已更新' },
  116. { value: 8, label: '审核未通过' },
  117. { value: 9, label: '审核中' },
  118. ],
  119. queryParam: {},
  120. columns: [
  121. {
  122. title: '操作',
  123. dataIndex: 'action',
  124. align: 'center',
  125. width: 150,
  126. scopedSlots: { customRender: 'action' },
  127. },
  128. {
  129. title: '盘点任务编号',
  130. dataIndex: 'number',
  131. align: 'left',
  132. width: 170,
  133. },
  134. {
  135. title: '盘点任务名称',
  136. dataIndex: 'taskName',
  137. align: 'left',
  138. width: 140,
  139. },
  140. {
  141. title: '盘点类型',
  142. dataIndex: 'taskType',
  143. align: 'left',
  144. width: 100,
  145. scopedSlots: { customRender: 'taskType' },
  146. },
  147. {
  148. title: '盘点仓库',
  149. dataIndex: 'depotName',
  150. align: 'left',
  151. width: 100,
  152. },
  153. {
  154. title: '商品数量',
  155. dataIndex: 'materialCount',
  156. align: 'left',
  157. width: 100,
  158. },
  159. {
  160. title: '盘点库位范围',
  161. dataIndex: 'positionRange',
  162. align: 'left',
  163. width: 120,
  164. },
  165. {
  166. title: '创建人',
  167. dataIndex: 'createByName',
  168. align: 'left',
  169. width: 100,
  170. },
  171. {
  172. title: '创建时间',
  173. dataIndex: 'createTime',
  174. align: 'left',
  175. width: 100,
  176. },
  177. {
  178. title: '盘点负责人',
  179. dataIndex: 'creatorName',
  180. align: 'left',
  181. width: 100,
  182. },
  183. {
  184. title: '盘点状态',
  185. dataIndex: 'taskStatus',
  186. align: 'left',
  187. width: 100,
  188. scopedSlots: { customRender: 'taskStatus' },
  189. },
  190. {
  191. title: '完成时间',
  192. dataIndex: 'operTime',
  193. align: 'left',
  194. width: 100,
  195. },
  196. ],
  197. dataSource: [],
  198. loading: false,
  199. rules: {
  200. taskType: { rules: [{ required: true, message: '请选择盘点类型' }] },
  201. depotId: { rules: [{ required: true, message: '请选择盘点仓库' }] },
  202. taskName: { rules: [{ required: true, message: '请输入盘点任务名称' }] },
  203. },
  204. url: {
  205. list: '/stocktaking/list',
  206. add: '/stocktaking/add',
  207. spinnerList: '/stocktaking/creatorSpinnerList',
  208. depotList: '/depot/findDepotByCurrentUser',
  209. delete: '/stocktaking/taskDelete/',
  210. cancel: '/stocktaking/taskCancel/',
  211. startTask: '/stocktaking/startTask/',
  212. },
  213. stockVisible: false,
  214. title: '',
  215. spinnerList: [],
  216. deoptData: [],
  217. taskId: '',
  218. openType: 'add',
  219. }
  220. },
  221. watch: {
  222. stockVisible(val) {
  223. if (!val) {
  224. this.loadData()
  225. }
  226. },
  227. },
  228. created() {
  229. this.getSpinnerList()
  230. this.getDepotList()
  231. },
  232. methods: {
  233. addTask(type, data) {
  234. this.taskId = ''
  235. this.openType = type
  236. this.title = type === 'add' ? '新增' : type === 'edit' ? '编辑' : '查看'
  237. if (type !== 'add') {
  238. this.getDetailList(data.id)
  239. }
  240. this.stockVisible = true
  241. },
  242. loadData(arg) {
  243. if (!this.url.list) {
  244. this.$message.error('请设置url.list属性!')
  245. return
  246. }
  247. //加载数据 若传入参数1则加载第一页的内容
  248. if (arg === 1) {
  249. this.ipagination.current = 1
  250. }
  251. this.loading = true
  252. const url = this.url.list + '?currentPage=' + this.ipagination.current + '&pageSize=' + this.ipagination.pageSize
  253. postAction(url, {
  254. ...this.queryParam
  255. }).then((res) => {
  256. if (res.code === 200) {
  257. this.dataSource = res.data.rows
  258. this.ipagination.total = Number(res.data.total)
  259. }else {
  260. this.$message.warning(res.msg)
  261. }
  262. this.loading = false
  263. this.onClearSelected()
  264. })
  265. },
  266. getDetailList(id) {
  267. this.taskId = id
  268. },
  269. getSpinnerList() {
  270. getAction(this.url.spinnerList).then((res) => {
  271. this.spinnerList = res.data || []
  272. })
  273. },
  274. getDepotList() {
  275. getAction(this.url.depotList).then((res) => {
  276. this.deoptData = res.data.map((item) => {
  277. return {
  278. label: item.depotName,
  279. value: item.id,
  280. }
  281. })
  282. })
  283. },
  284. handleDelete(id) {
  285. const ids = id || this.selectedRowKeys
  286. const url = this.url.delete + ids
  287. getAction(url)
  288. .then((res) => {
  289. this.$message.success('删除成功')
  290. this.loadData()
  291. })
  292. .catch((err) => {
  293. this.$message.error('删除失败')
  294. })
  295. },
  296. cancelTask() {
  297. const ids = this.selectedRowKeys
  298. const url = this.url.cancel + ids
  299. getAction(url)
  300. .then((res) => {
  301. this.$message.success('取消成功')
  302. this.loadData()
  303. })
  304. .catch((err) => {
  305. this.$message.error('取消失败')
  306. })
  307. },
  308. //开始盘点
  309. onStartTask() {
  310. const ids = this.selectedRowKeys
  311. const url = this.url.startTask + ids
  312. getAction(url)
  313. .then((res) => {
  314. this.$message.success('盘点成功')
  315. this.loadData()
  316. })
  317. .catch((err) => {
  318. this.$message.error('盘点失败')
  319. })
  320. },
  321. formateTaskStatus(type) {
  322. const target = this.taskStatusList.find(item => item.value == type)
  323. return target?target.label:''
  324. },
  325. getCheckboxProps(record) {
  326. return {
  327. props: {
  328. disabled: record.taskStatus !== 1,
  329. },
  330. }
  331. },
  332. },
  333. }
  334. </script>
  335. <style scoped>
  336. @import '~@assets/less/common.less';
  337. </style>