list.vue 15 KB

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