list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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.trim="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="dpaudit" slot-scope="text, record">
  68. <stateIcon v-if="record.state!='AUDIT_REJECT'" :state="record.state !== 'WAIT_SUBMIT'&&record.state !== 'WAIT_AUDIT'?'1':'2'"></stateIcon>
  69. <stateIcon :title="record.stateDictValue" v-else :state="0"></stateIcon>
  70. </template>
  71. <!-- 财务人审核 -->
  72. <template slot="cwaudit" slot-scope="text, record">
  73. <stateIcon :state="record.state == 'FINISH'?'1':'2'"></stateIcon>
  74. </template>
  75. <!-- 操作 -->
  76. <template slot="action" slot-scope="text, record">
  77. <a-button
  78. size="small"
  79. type="link"
  80. v-if="(record.state == 'WAIT_SUBMIT') || (record.state == 'AUDIT_REJECT') && $hasPermissions('B_inventoryCheckingEdit')"
  81. class="button-primary"
  82. @click="handleEdit(record)"
  83. >编辑</a-button>
  84. <a-button
  85. size="small"
  86. type="link"
  87. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_inventoryCheckingAudit')"
  88. class="button-primary"
  89. @click="handleEexamine(record)"
  90. >审核</a-button>
  91. <a-button
  92. size="small"
  93. type="link"
  94. v-if="record.state == 'WAIT_CHECK_WAREHOUSE' && $hasPermissions('B_inventoryCheckingInventory')"
  95. class="button-primary"
  96. @click="handleWarehouse(record)"
  97. >盘点</a-button>
  98. <a-button
  99. size="small"
  100. type="link"
  101. v-if="record.state == 'WAIT_CHECK_WAREHOUSE' && $hasPermissions('B_inventoryCheckingAgain')"
  102. class="button-primary"
  103. @click="handleAgain(record)"
  104. >重盘</a-button>
  105. <a-button
  106. size="small"
  107. type="link"
  108. v-if="(record.state == 'WAIT_SUBMIT') || (record.state == 'AUDIT_REJECT') && $hasPermissions('B_inventoryCheckingDel')"
  109. class="button-error"
  110. @click="handleDel(record)"
  111. >删除</a-button>
  112. <span
  113. v-if="!((record.state == 'WAIT_SUBMIT') || (record.state == 'AUDIT_REJECT') && ($hasPermissions('B_inventoryCheckingEdit') || $hasPermissions('B_inventoryCheckingDel')))
  114. && !(record.state == 'WAIT_AUDIT' && $hasPermissions('B_inventoryCheckingAudit'))
  115. && !(record.state == 'WAIT_CHECK_WAREHOUSE' && ($hasPermissions('B_inventoryCheckingInventory') || $hasPermissions('B_inventoryCheckingAgain')))">--</span>
  116. </template>
  117. </s-table>
  118. <!-- 基础信息 -->
  119. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  120. <!-- 审核 -->
  121. <auditModal :openModal="visibleAudit" :spinning="spinningAudit" @close="visibleAudit=false" @ok="auditOrder(true)" @fail="auditOrder(false)" />
  122. <!-- 详情 -->
  123. <inventoryChecking-detail-modal :openModal="openDetailModal" :itemSn="itemSn" @close="handleDetailClose" />
  124. </a-card>
  125. </template>
  126. <script>
  127. import { commonMixin } from '@/utils/mixin'
  128. import { STable, VSelect } from '@/components'
  129. import rangeDate from '@/views/common/rangeDate.vue'
  130. import auditModal from '@/views/common/auditModal.vue'
  131. import basicInfoModal from './basicInfoModal.vue'
  132. import inventoryCheckingDetailModal from './detailModal.vue'
  133. import stateIcon from '@/views/common/stateIcon'
  134. import { checkWarehouseList, checkWarehouseDel, checkWarehouseAudit, checkWarehouseValidate, checkWarehouseReInventory } from '@/api/checkWarehouse'
  135. export default {
  136. name: 'InventoryCheckingList',
  137. components: { STable, VSelect, rangeDate, auditModal, basicInfoModal, inventoryCheckingDetailModal, stateIcon },
  138. mixins: [commonMixin],
  139. data () {
  140. return {
  141. queryParam: { // 查询条件
  142. checkWarehouseNo: '',
  143. checkType: undefined,
  144. warehouseFlag: undefined,
  145. state: undefined,
  146. beginDate: '', // 创建时间 开始时间
  147. endDate: '' // 创建时间 结束时间
  148. },
  149. tableHeight: 0,
  150. advanced: true,
  151. disabled: false, // 查询、重置按钮是否可操作
  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. computed: {
  181. columns () {
  182. const arr = [
  183. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  184. { title: '盘点单号', scopedSlots: { customRender: 'checkWarehouseNo' }, width: '12%', align: 'center' },
  185. { title: '总款数', dataIndex: 'productTotalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  186. { title: '总数量', dataIndex: 'totalStockQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  187. // { title: '总成本', dataIndex: 'totalStockCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  188. { title: '盘点类型', dataIndex: 'checkTypeDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  189. { title: '是否区分仓库', dataIndex: 'warehouseFlagDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  190. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  191. { title: '审核时间', dataIndex: 'checkSuperviseTime', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  192. { title: '状态', dataIndex: 'stateDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  193. { title: '监盘人审核', scopedSlots: { customRender: 'dpaudit' }, width: '3%', align: 'center' },
  194. { title: '财务人审核', scopedSlots: { customRender: 'cwaudit' }, width: '3%', align: 'center' },
  195. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  196. ]
  197. if (this.$hasPermissions('M_ShowAllCost')) {
  198. arr.splice(4, 0, { title: '总成本', dataIndex: 'totalStockCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  199. }
  200. return arr
  201. }
  202. },
  203. methods: {
  204. // 时间 change
  205. dateChange (date) {
  206. this.queryParam.beginDate = date[0]
  207. this.queryParam.endDate = date[1]
  208. },
  209. // 重置
  210. resetSearchForm () {
  211. this.queryParam.checkWarehouseNo = ''
  212. this.queryParam.checkType = undefined
  213. this.queryParam.warehouseFlag = undefined
  214. this.queryParam.state = undefined
  215. this.queryParam.beginDate = ''
  216. this.queryParam.endDate = ''
  217. this.$refs.rangeDate.resetDate()
  218. this.$refs.table.refresh(true)
  219. },
  220. // 新增
  221. handleAdd () {
  222. const _this = this
  223. this.$confirm({
  224. title: '提示',
  225. content: '如果开始盘点,不能再进行其他与产品出入库相关的操作。确认开始盘点吗?',
  226. centered: true,
  227. onOk () {
  228. // checkWarehouseValidate({}).then(res => {
  229. // if (res.status == 200) {
  230. // if (res.data) {
  231. _this.openModal = true
  232. // } else {
  233. // _this.$message.info('存在未完结的盘点单,不能新增,请先完成盘点后再新增')
  234. // }
  235. // }
  236. // })
  237. }
  238. })
  239. },
  240. // 编辑
  241. handleEdit (row) {
  242. if (row.checkType == 'ALL') { // 全盘
  243. this.$router.push({ path: `/inventoryManagement/inventoryChecking/overall/${row.id}/${row.checkWarehouseSn}` })
  244. } else if (row.checkType == 'SELECT') { // 自选盘点
  245. this.$router.push({ path: `/inventoryManagement/inventoryChecking/selfDisk/${row.id}/${row.checkWarehouseSn}` })
  246. }
  247. },
  248. // 详情
  249. handleDetail (row) {
  250. this.itemSn = row.checkWarehouseSn
  251. this.openDetailModal = true
  252. },
  253. // 盘点
  254. handleWarehouse (row) {
  255. this.$router.push({ path: `/inventoryManagement/inventoryChecking/makeInventory/${row.id}/${row.checkWarehouseSn}` })
  256. },
  257. // 重盘
  258. handleAgain (row) {
  259. const _this = this
  260. this.$confirm({
  261. title: '提示',
  262. content: '重新盘点后,盘点单状态回退到待提交。确认重新盘点吗?',
  263. centered: true,
  264. onOk () {
  265. checkWarehouseReInventory({ id: row.id }).then(res => {
  266. if (res.status == 200) {
  267. _this.$message.success(res.message)
  268. _this.$refs.table.refresh()
  269. }
  270. })
  271. }
  272. })
  273. },
  274. // 基本信息 保存
  275. handleOk (data) {
  276. this.handleEdit(data)
  277. },
  278. // 删除
  279. handleDel (row) {
  280. const _this = this
  281. this.$confirm({
  282. title: '提示',
  283. content: '删除后不可恢复,确定要进行删除吗?',
  284. centered: true,
  285. onOk () {
  286. checkWarehouseDel({ id: row.id }).then(res => {
  287. if (res.status == 200) {
  288. _this.$message.success(res.message)
  289. _this.$refs.table.refresh()
  290. }
  291. })
  292. }
  293. })
  294. },
  295. // 审核
  296. handleEexamine (row) {
  297. this.auditInfo = row
  298. this.visibleAudit = true
  299. },
  300. auditOrder (billStatus) {
  301. this.spinningAudit = true
  302. checkWarehouseAudit({
  303. id: this.auditInfo.id,
  304. auditFlag: billStatus
  305. }).then(res => {
  306. if (res.status == 200) {
  307. this.visibleAudit = false
  308. this.$message.success(res.message)
  309. this.$refs.table.refresh()
  310. this.spinningAudit = false
  311. } else {
  312. this.visibleAudit = false
  313. this.spinningAudit = false
  314. }
  315. })
  316. },
  317. handleDetailClose () {
  318. this.itemSn = null
  319. this.openDetailModal = false
  320. },
  321. pageInit () {
  322. const _this = this
  323. this.$nextTick(() => { // 页面渲染完成后的回调
  324. _this.setTableH()
  325. })
  326. },
  327. setTableH () {
  328. const tableSearchH = this.$refs.tableSearch.offsetHeight
  329. this.tableHeight = window.innerHeight - tableSearchH - 235
  330. }
  331. },
  332. watch: {
  333. advanced (newValue, oldValue) {
  334. const _this = this
  335. this.$nextTick(() => { // 页面渲染完成后的回调
  336. _this.setTableH()
  337. })
  338. },
  339. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  340. this.setTableH()
  341. }
  342. },
  343. mounted () {
  344. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  345. this.pageInit()
  346. this.resetSearchForm()
  347. }
  348. },
  349. activated () {
  350. // 如果是新页签打开,则重置当前页面
  351. if (this.$store.state.app.isNewTab) {
  352. this.pageInit()
  353. this.resetSearchForm()
  354. }
  355. // 仅刷新列表,不重置页面
  356. if (this.$store.state.app.updateList) {
  357. this.pageInit()
  358. this.$refs.table.refresh()
  359. }
  360. },
  361. beforeRouteEnter (to, from, next) {
  362. next(vm => {})
  363. }
  364. }
  365. </script>