list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <a-card size="small" :bordered="false" class="inventoryCheckingList-wrap">
  3. <!-- 搜索条件 -->
  4. <div ref="tableSearch" class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="盘点单号">
  9. <a-input id="inventoryCheckingList-checkWarehouseNo" v-model="queryParam.checkWarehouseNo" allowClear placeholder="请输入盘点单号"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="盘点类型">
  14. <v-select code="CHECK_WAREHOUSE_TYPE" id="inventoryCheckingList-checkType" v-model="queryParam.checkType" allowClear placeholder="请选择盘点类型"></v-select>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="是否区分仓库">
  19. <v-select code="FLAG" id="inventoryCheckingList-warehouseFlag" v-model="queryParam.warehouseFlag" allowClear placeholder="请选择"></v-select>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="状态">
  25. <v-select code="CHECK_WAREHOUSE_STATE" id="inventoryCheckingList-state" v-model="queryParam.state" allowClear placeholder="请选择状态"></v-select>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="创建时间">
  30. <rangeDate ref="rangeDate" :value="[queryParam.beginDate, queryParam.endDate]" @change="dateChange" />
  31. </a-form-item>
  32. </a-col>
  33. </template>
  34. <a-col :md="6" :sm="24">
  35. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryCheckingList-refresh">查询</a-button>
  36. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryCheckingList-reset">重置</a-button>
  37. <a @click="advanced=!advanced" style="margin-left: 5px">
  38. {{ advanced ? '收起' : '展开' }}
  39. <a-icon :type="advanced ? 'up' : 'down'"/>
  40. </a>
  41. </a-col>
  42. </a-row>
  43. </a-form>
  44. </div>
  45. <!-- 操作按钮 -->
  46. <div class="table-operator">
  47. <a-button id="inventoryCheckingList-add" v-if="$hasPermissions('B_inventoryCheckingAdd')" type="primary" class="button-error" @click="handleAdd">新增</a-button>
  48. </div>
  49. <!-- 列表 -->
  50. <s-table
  51. class="sTable fixPagination"
  52. ref="table"
  53. :style="{ height: tableHeight+84.5+'px' }"
  54. size="small"
  55. :rowKey="(record) => record.id"
  56. :columns="columns"
  57. :data="loadData"
  58. :scroll="{ y: tableHeight }"
  59. :defaultLoadData="false"
  60. bordered>
  61. <!-- 单号 -->
  62. <template slot="checkWarehouseNo" slot-scope="text, record">
  63. <span style="color: #ed1c24;cursor: pointer;" v-if="$hasPermissions('B_inventoryCheckingDetail')" @click="handleDetail(record)">{{ record.checkWarehouseNo }}</span>
  64. <span v-else>{{ record.checkWarehouseNo }}</span>
  65. </template>
  66. <!-- 操作 -->
  67. <template slot="action" slot-scope="text, record">
  68. <a-button
  69. size="small"
  70. type="link"
  71. v-if="(record.state == 'WAIT_SUBMIT') || (record.state == 'AUDIT_REJECT') && $hasPermissions('B_inventoryCheckingEdit')"
  72. class="button-info"
  73. @click="handleEdit(record)"
  74. >编辑</a-button>
  75. <a-button
  76. size="small"
  77. type="link"
  78. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_inventoryCheckingAudit')"
  79. class="button-warning"
  80. @click="handleEexamine(record)"
  81. >审核</a-button>
  82. <a-button
  83. size="small"
  84. type="link"
  85. v-if="record.state == 'WAIT_CHECK_WAREHOUSE' && $hasPermissions('B_inventoryCheckingInventory')"
  86. class="button-warning"
  87. @click="handleWarehouse(record)"
  88. >盘点</a-button>
  89. <a-button
  90. size="small"
  91. type="link"
  92. v-if="record.state == 'WAIT_CHECK_WAREHOUSE' && $hasPermissions('B_inventoryCheckingAgain')"
  93. class="button-warning"
  94. @click="handleAgain(record)"
  95. >重盘</a-button>
  96. <a-button
  97. size="small"
  98. type="link"
  99. v-if="(record.state == 'WAIT_SUBMIT') || (record.state == 'AUDIT_REJECT') && $hasPermissions('B_inventoryCheckingDel')"
  100. class="button-error"
  101. @click="handleDel(record)"
  102. >删除</a-button>
  103. <span
  104. v-if="!((record.state == 'WAIT_SUBMIT') || (record.state == 'AUDIT_REJECT') && ($hasPermissions('B_inventoryCheckingEdit') || $hasPermissions('B_inventoryCheckingDel')))
  105. && !(record.state == 'WAIT_AUDIT' && $hasPermissions('B_inventoryCheckingAudit'))
  106. && !(record.state == 'WAIT_CHECK_WAREHOUSE' && ($hasPermissions('B_inventoryCheckingInventory') || $hasPermissions('B_inventoryCheckingAgain')))">--</span>
  107. </template>
  108. </s-table>
  109. <!-- 基础信息 -->
  110. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  111. <!-- 审核 -->
  112. <auditModal :openModal="visibleAudit" :spinning="spinningAudit" @close="visibleAudit=false" @ok="auditOrder(true)" @fail="auditOrder(false)" />
  113. <!-- 详情 -->
  114. <inventoryChecking-detail-modal :openModal="openDetailModal" :itemSn="itemSn" @close="handleDetailClose" />
  115. </a-card>
  116. </template>
  117. <script>
  118. import { STable, VSelect } from '@/components'
  119. import rangeDate from '@/views/common/rangeDate.vue'
  120. import auditModal from '@/views/common/auditModal.vue'
  121. import basicInfoModal from './basicInfoModal.vue'
  122. import inventoryCheckingDetailModal from './detailModal.vue'
  123. import { checkWarehouseList, checkWarehouseDel, checkWarehouseAudit, checkWarehouseValidate, checkWarehouseReInventory } from '@/api/checkWarehouse'
  124. export default {
  125. components: { STable, VSelect, rangeDate, auditModal, basicInfoModal, inventoryCheckingDetailModal },
  126. data () {
  127. return {
  128. queryParam: { // 查询条件
  129. checkWarehouseNo: '',
  130. checkType: undefined,
  131. warehouseFlag: undefined,
  132. state: undefined,
  133. beginDate: '', // 创建时间 开始时间
  134. endDate: '' // 创建时间 结束时间
  135. },
  136. tableHeight: 0,
  137. advanced: true,
  138. disabled: false, // 查询、重置按钮是否可操作
  139. columns: [
  140. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  141. { title: '盘点单号', scopedSlots: { customRender: 'checkWarehouseNo' }, width: '15%', align: 'center' },
  142. { title: '总款数', dataIndex: 'productTotalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  143. { title: '总数量', dataIndex: 'totalStockQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  144. { title: '总成本', dataIndex: 'totalStockCost', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  145. { title: '盘点类型', dataIndex: 'checkTypeDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '是否区分仓库', dataIndex: 'warehouseFlagDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '状态', dataIndex: 'stateDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  148. { title: '创建时间', dataIndex: 'createDate', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '审核时间', dataIndex: 'checkSuperviseTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  150. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  151. ],
  152. // 加载数据方法 必须为 Promise 对象
  153. loadData: parameter => {
  154. this.disabled = true
  155. this.spinning = true
  156. return checkWarehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  157. let data
  158. if (res.status == 200) {
  159. data = res.data
  160. const no = (data.pageNo - 1) * data.pageSize
  161. for (var i = 0; i < data.list.length; i++) {
  162. data.list[i].no = no + i + 1
  163. }
  164. this.disabled = false
  165. }
  166. this.spinning = false
  167. return data
  168. })
  169. },
  170. openModal: false, // 新增编辑 弹框
  171. itemId: '', // 当前id
  172. nowData: null, // 当前记录数据
  173. visibleAudit: false,
  174. auditInfo: null,
  175. spinningAudit: false,
  176. openDetailModal: false,
  177. itemSn: null
  178. }
  179. },
  180. methods: {
  181. // 时间 change
  182. dateChange (date) {
  183. this.queryParam.beginDate = date[0]
  184. this.queryParam.endDate = date[1]
  185. },
  186. // 重置
  187. resetSearchForm () {
  188. this.queryParam.checkWarehouseNo = ''
  189. this.queryParam.checkType = undefined
  190. this.queryParam.warehouseFlag = undefined
  191. this.queryParam.state = undefined
  192. this.queryParam.beginDate = ''
  193. this.queryParam.endDate = ''
  194. this.$refs.rangeDate.resetDate()
  195. this.$refs.table.refresh(true)
  196. },
  197. // 新增
  198. handleAdd () {
  199. const _this = this
  200. this.$confirm({
  201. title: '提示',
  202. content: '如果开始盘点,不能再进行其他与产品出入库相关的操作。确认开始盘点吗?',
  203. centered: true,
  204. onOk () {
  205. // checkWarehouseValidate({}).then(res => {
  206. // if (res.status == 200) {
  207. // if (res.data) {
  208. _this.openModal = true
  209. // } else {
  210. // _this.$message.info('存在未完结的盘点单,不能新增,请先完成盘点后再新增')
  211. // }
  212. // }
  213. // })
  214. }
  215. })
  216. },
  217. // 编辑
  218. handleEdit (row) {
  219. if (row.checkType == 'ALL') { // 全盘
  220. this.$router.push({ path: `/inventoryManagement/inventoryChecking/overall/${row.id}/${row.checkWarehouseSn}` })
  221. } else if (row.checkType == 'SELECT') { // 自选盘点
  222. this.$router.push({ path: `/inventoryManagement/inventoryChecking/selfDisk/${row.id}/${row.checkWarehouseSn}` })
  223. }
  224. },
  225. // 详情
  226. handleDetail (row) {
  227. this.itemSn = row.checkWarehouseSn
  228. this.openDetailModal = true
  229. },
  230. // 盘点
  231. handleWarehouse (row) {
  232. this.$router.push({ path: `/inventoryManagement/inventoryChecking/makeInventory/${row.id}/${row.checkWarehouseSn}` })
  233. },
  234. // 重盘
  235. handleAgain (row) {
  236. const _this = this
  237. this.$confirm({
  238. title: '提示',
  239. content: '重新盘点后,盘点单状态回退到待提交。确认重新盘点吗?',
  240. centered: true,
  241. onOk () {
  242. checkWarehouseReInventory({ id: row.id }).then(res => {
  243. if (res.status == 200) {
  244. _this.$message.success(res.message)
  245. _this.$refs.table.refresh()
  246. }
  247. })
  248. }
  249. })
  250. },
  251. // 基本信息 保存
  252. handleOk (data) {
  253. this.handleEdit(data)
  254. },
  255. // 删除
  256. handleDel (row) {
  257. const _this = this
  258. this.$confirm({
  259. title: '提示',
  260. content: '删除后不可恢复,确定要进行删除吗?',
  261. centered: true,
  262. onOk () {
  263. checkWarehouseDel({ id: row.id }).then(res => {
  264. if (res.status == 200) {
  265. _this.$message.success(res.message)
  266. _this.$refs.table.refresh()
  267. }
  268. })
  269. }
  270. })
  271. },
  272. // 审核
  273. handleEexamine (row) {
  274. this.auditInfo = row
  275. this.visibleAudit = true
  276. },
  277. auditOrder (billStatus) {
  278. this.spinningAudit = true
  279. checkWarehouseAudit({
  280. id: this.auditInfo.id,
  281. auditFlag: billStatus
  282. }).then(res => {
  283. if (res.status == 200) {
  284. this.visibleAudit = false
  285. this.$message.success(res.message)
  286. this.$refs.table.refresh()
  287. this.spinningAudit = false
  288. } else {
  289. this.visibleAudit = false
  290. this.spinningAudit = false
  291. }
  292. })
  293. },
  294. handleDetailClose () {
  295. this.itemSn = null
  296. this.openDetailModal = false
  297. },
  298. pageInit () {
  299. const _this = this
  300. this.$nextTick(() => { // 页面渲染完成后的回调
  301. _this.setTableH()
  302. })
  303. },
  304. setTableH () {
  305. const tableSearchH = this.$refs.tableSearch.offsetHeight
  306. this.tableHeight = window.innerHeight - tableSearchH - 235
  307. }
  308. },
  309. watch: {
  310. advanced (newValue, oldValue) {
  311. const _this = this
  312. this.$nextTick(() => { // 页面渲染完成后的回调
  313. _this.setTableH()
  314. })
  315. },
  316. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  317. this.setTableH()
  318. }
  319. },
  320. mounted () {
  321. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  322. this.pageInit()
  323. this.resetSearchForm()
  324. }
  325. },
  326. activated () {
  327. // 如果是新页签打开,则重置当前页面
  328. if (this.$store.state.app.isNewTab) {
  329. this.pageInit()
  330. this.resetSearchForm()
  331. }
  332. // 仅刷新列表,不重置页面
  333. if (this.$store.state.app.updateList) {
  334. this.pageInit()
  335. this.$refs.table.refresh()
  336. }
  337. },
  338. beforeRouteEnter (to, from, next) {
  339. next(vm => {})
  340. }
  341. }
  342. </script>