list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <a-card size="small" :bordered="false" class="inventoryCheckAuditList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="盘点单号">
  10. <a-input id="inventoryCheckAuditList-checkWarehouseNo" v-model.trim="queryParam.checkWarehouseNo" allowClear placeholder="请输入盘点单号"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="盘点完成时间">
  15. <rangeDate ref="rangeDate" @change="dateChange" />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <span class="table-page-search-submitButtons">
  20. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryCheckAuditList-refresh">查询</a-button>
  21. <a-button style="margin-left: 8px" @click="resetSearchForm()" :disabled="disabled" id="inventoryCheckAuditList-reset">重置</a-button>
  22. </span>
  23. </a-col>
  24. </a-row>
  25. </a-form>
  26. </div>
  27. <!-- 列表 -->
  28. <s-table
  29. class="sTable fixPagination"
  30. ref="table"
  31. :style="{ height: tableHeight+84.5+'px' }"
  32. size="small"
  33. :rowKey="(record) => record.id"
  34. :columns="columns"
  35. :data="loadData"
  36. :scroll="{ y: tableHeight }"
  37. :defaultLoadData="false"
  38. bordered>
  39. <!-- 单号 -->
  40. <template slot="checkWarehouseNo" slot-scope="text, record">
  41. <span style="color: #ed1c24;cursor: pointer;" v-if="$hasPermissions('B_inventoryCheckingDetail')" @click="handleDetail(record)">{{ record.checkWarehouseNo }}</span>
  42. <span v-else>{{ record.checkWarehouseNo }}</span>
  43. </template>
  44. <!-- 盈亏数量 -->
  45. <template slot="totalLossQty" slot-scope="text, record">
  46. <span>{{ (record.totalLossQty || record.totalLossQty==0) ? Math.abs(record.totalLossQty) : '--' }}</span>
  47. </template>
  48. <!-- 审核 -->
  49. <template slot="audit" slot-scope="text, record">
  50. <stateIcon :title="record.stateDictValue" :state="record.state == 'FINISH'?'1':'2'"></stateIcon>
  51. </template>
  52. <!-- 操作 -->
  53. <template slot="action" slot-scope="text, record">
  54. <a-button
  55. size="small"
  56. v-if="record.state=='WAIT_FINANCE_AUDIT' && $hasPermissions('B_inventoryCheckAuditAudit')"
  57. type="link"
  58. class="button-primary"
  59. @click="handleOk(record, true)"
  60. id="warehousingAudit-adopt-btn">通过</a-button>
  61. <a-button
  62. size="small"
  63. type="link"
  64. v-if="record.state == 'WAIT_FINANCE_AUDIT' && $hasPermissions('B_inventoryCheckingAgain')"
  65. class="button-error"
  66. @click="handleAgain(record)"
  67. >重盘</a-button>
  68. <span v-if="!(record.state=='WAIT_FINANCE_AUDIT' && ($hasPermissions('B_inventoryCheckAuditAudit') || $hasPermissions('B_inventoryCheckingAgain')))">--</span>
  69. </template>
  70. </s-table>
  71. </a-spin>
  72. <!-- 详情 -->
  73. <inventoryChecking-detail-modal :openModal="openDetailModal" :itemSn="itemSn" @close="handleDetailClose" />
  74. <!-- 设置成本价 -->
  75. <setPriceModal ref="setPriceModal" @ok="handleOk" :openModal="openCostPriceModal" @close="openCostPriceModal=false"></setPriceModal>
  76. </a-card>
  77. </template>
  78. <script>
  79. import { commonMixin } from '@/utils/mixin'
  80. import { STable, VSelect } from '@/components'
  81. import rangeDate from '@/views/common/rangeDate.vue'
  82. import stateIcon from '@/views/common/stateIcon'
  83. import inventoryCheckingDetailModal from '@/views/inventoryManagement/inventoryChecking/detailModal.vue'
  84. import setPriceModal from './setPriceModal.vue'
  85. import { checkWarehouseAuditList, checkWarehouseFinanceAudit, checkWarehouseReInventory, queryStockProductCostNull } from '@/api/checkWarehouse'
  86. export default {
  87. name: 'InventoryCheckingList',
  88. components: { STable, VSelect, rangeDate, inventoryCheckingDetailModal, stateIcon, setPriceModal },
  89. mixins: [commonMixin],
  90. data () {
  91. return {
  92. spinning: false,
  93. disabled: false, // 查询、重置按钮是否可操作
  94. tableHeight: 0,
  95. // 查询参数
  96. queryParam: {
  97. beginDate: undefined,
  98. endDate: undefined,
  99. checkWarehouseNo: ''
  100. },
  101. // 表头
  102. columns: [
  103. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  104. { title: '盘点单号', scopedSlots: { customRender: 'checkWarehouseNo' }, width: '15%', align: 'center' },
  105. { title: '总款数', dataIndex: 'productTotalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  106. { title: '总数量', dataIndex: 'totalStockQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  107. { title: '总成本', dataIndex: 'totalStockCost', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  108. { title: '盘盈数量', dataIndex: 'totalProfitQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  109. { title: '盘亏数量', scopedSlots: { customRender: 'totalLossQty' }, width: '7%', align: 'center' },
  110. { title: '盘点完成时间', dataIndex: 'checkTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '财务审核时间', dataIndex: 'financeAuditTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  112. // { title: '财务审核状态', dataIndex: 'stateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  113. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '3%', align: 'center' },
  114. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  115. ],
  116. // 加载数据方法 必须为 Promise 对象
  117. loadData: parameter => {
  118. this.disabled = true
  119. this.spinning = true
  120. return checkWarehouseAuditList(Object.assign(parameter, this.queryParam)).then(res => {
  121. let data
  122. if (res.status == 200) {
  123. data = res.data
  124. const no = (data.pageNo - 1) * data.pageSize
  125. for (var i = 0; i < data.list.length; i++) {
  126. data.list[i].no = no + i + 1
  127. data.list[i].financeFinishTime = data.list[i].financeAuditTime
  128. }
  129. this.disabled = false
  130. }
  131. this.spinning = false
  132. return data
  133. })
  134. },
  135. productTotal: null,
  136. openDetailModal: false,
  137. openCostPriceModal: false,
  138. itemSn: null
  139. }
  140. },
  141. methods: {
  142. // 时间 change
  143. dateChange (date) {
  144. this.queryParam.beginDate = date[0]
  145. this.queryParam.endDate = date[1]
  146. },
  147. // 详情
  148. handleDetail (row) {
  149. this.itemSn = row.checkWarehouseSn
  150. this.openDetailModal = true
  151. },
  152. handleDetailClose () {
  153. this.itemSn = null
  154. this.openDetailModal = false
  155. },
  156. handleOk (row, type) {
  157. queryStockProductCostNull({ checkWarehouseSn: row.checkWarehouseSn }).then(res => {
  158. console.log(res)
  159. // 设置成本价
  160. if (res.data.length) {
  161. // 如果有盈亏的产品,没有最近一次入库成本价,需要设置成本价
  162. this.setCostPrice(res.data, row)
  163. } else {
  164. this.handleExamine(row, type)
  165. }
  166. })
  167. },
  168. // 审核
  169. handleExamine (row, type) {
  170. const _this = this
  171. this.$confirm({
  172. title: '提示',
  173. content: '确定要进行' + (type ? ' 通过 ' : ' 不通过 ') + '操作吗?',
  174. centered: true,
  175. onOk () {
  176. _this.spinning = true
  177. checkWarehouseFinanceAudit({ id: row.id, auditFlag: type }).then(res => {
  178. if (res.status == 200) {
  179. _this.$message.success(res.message)
  180. _this.$refs.table.refresh()
  181. _this.spinning = false
  182. } else {
  183. _this.spinning = false
  184. }
  185. })
  186. }
  187. })
  188. },
  189. // 设置成本价
  190. setCostPrice (data, row) {
  191. this.openCostPriceModal = true
  192. this.$nextTick(() => {
  193. this.$refs.setPriceModal.setData(data, row)
  194. })
  195. },
  196. // 重盘
  197. handleAgain (row) {
  198. const _this = this
  199. this.$confirm({
  200. title: '提示',
  201. content: '重新盘点后,盘点单状态回退到待提交。确认重新盘点吗?',
  202. centered: true,
  203. onOk () {
  204. checkWarehouseReInventory({ id: row.id }).then(res => {
  205. if (res.status == 200) {
  206. _this.$message.success(res.message)
  207. _this.$refs.table.refresh()
  208. }
  209. })
  210. }
  211. })
  212. },
  213. // 重置
  214. resetSearchForm () {
  215. this.$refs.rangeDate.resetDate()
  216. this.queryParam.beginDate = undefined
  217. this.queryParam.endDate = undefined
  218. this.queryParam.checkWarehouseNo = ''
  219. this.$refs.table.refresh(true)
  220. },
  221. pageInit () {
  222. const _this = this
  223. this.$nextTick(() => { // 页面渲染完成后的回调
  224. _this.setTableH()
  225. })
  226. },
  227. setTableH () {
  228. const tableSearchH = this.$refs.tableSearch.offsetHeight
  229. this.tableHeight = window.innerHeight - tableSearchH - 195
  230. }
  231. },
  232. watch: {
  233. advanced (newValue, oldValue) {
  234. const _this = this
  235. this.$nextTick(() => { // 页面渲染完成后的回调
  236. _this.setTableH()
  237. })
  238. },
  239. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  240. this.setTableH()
  241. }
  242. },
  243. mounted () {
  244. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  245. this.pageInit()
  246. this.resetSearchForm()
  247. }
  248. },
  249. activated () {
  250. // 如果是新页签打开,则重置当前页面
  251. if (this.$store.state.app.isNewTab) {
  252. this.pageInit()
  253. this.resetSearchForm()
  254. }
  255. },
  256. beforeRouteEnter (to, from, next) {
  257. next(vm => {})
  258. }
  259. }
  260. </script>