list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <a-card size="small" :bordered="false" class="inventoryCheckList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 标签页 -->
  5. <a-tabs type="card" :default-active-key="queryParam.deleteFlag" @change="handleTabChange" class="inventoryCheckList-tabs">
  6. <a-tab-pane v-for="item in tabPaneData" :key="item.type">
  7. <span slot="tab">{{ item.name }}</span>
  8. </a-tab-pane>
  9. </a-tabs>
  10. <!-- 搜索条件 -->
  11. <div ref="tableSearch" class="table-page-search-wrapper">
  12. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-item label="盘点单号">
  16. <a-input id="inventoryCheckList-checkWarehouseNo" v-model.trim="queryParam.checkWarehouseNo" allowClear placeholder="请输入盘点单号"/>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="4" :sm="24" v-show="isShowWarehouse">
  20. <a-form-item label="仓库">
  21. <warehouse
  22. v-model="queryParam.warehouseSn"
  23. isPermission
  24. id="inventoryCheckList-warehouseSn"
  25. placeholder="请选择仓库"
  26. />
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="4" :sm="24">
  30. <a-form-item label="盘点状态">
  31. <v-select
  32. v-model="queryParam.checkState"
  33. ref="checkState"
  34. id="inventoryCheckList-checkState"
  35. code="CHECK_WAREHOUSE_STATE"
  36. placeholder="请选择盘点状态"
  37. allowClear
  38. ></v-select>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :md="4" :sm="24">
  42. <a-form-item label="监盘状态">
  43. <v-select
  44. v-model="queryParam.checkSuperviseState"
  45. ref="checkSuperviseState"
  46. id="inventoryCheckList-checkSuperviseState"
  47. code="CHECK_WAREHOUSE_SUPERVISE_STATE"
  48. placeholder="请选择监盘状态"
  49. allowClear
  50. ></v-select>
  51. </a-form-item>
  52. </a-col>
  53. <a-col :md="6" :sm="24">
  54. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryCheckList-refresh">查询</a-button>
  55. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryCheckList-reset">重置</a-button>
  56. </a-col>
  57. </a-row>
  58. </a-form>
  59. </div>
  60. <!-- 操作按钮 -->
  61. <div class="table-operator">
  62. <a-button v-if="$hasPermissions('B_inventoryCheckAdd')" id="inventoryCheckList-add" type="primary" class="button-error" @click="handleAdd">新增</a-button>
  63. </div>
  64. <!-- 列表 -->
  65. <s-table
  66. class="sTable fixPagination"
  67. ref="table"
  68. :style="{ height: tableHeight+84.5+'px' }"
  69. size="small"
  70. :rowKey="(record) => record.id"
  71. :columns="columns"
  72. :data="loadData"
  73. :scroll="{ y: tableHeight }"
  74. :defaultLoadData="false"
  75. bordered>
  76. <!-- 操作 -->
  77. <template slot="action" slot-scope="text, record">
  78. <a-button
  79. size="small"
  80. type="link"
  81. v-if="$hasPermissions('B_inventoryCheckDetail')"
  82. class="button-success"
  83. @click="handleDetail(record)"
  84. id="inventoryCheckList-audit-btn">详情</a-button>
  85. <span v-else>--</span>
  86. </template>
  87. </s-table>
  88. </a-spin>
  89. <!-- 新增盘点单 -->
  90. <inventory-check-add-modal :openModal="openAddModal" @ok="handleAddOk" @close="openAddModal=false" />
  91. <!-- 盘点校验 -->
  92. <common-modal
  93. :openModal="openCommonModal"
  94. :modalHtml="modalHtml"
  95. okText="好的"
  96. :isCancel="false"
  97. @ok="openCommonModal=false"
  98. @cancel="openCommonModal=false" />
  99. </a-card>
  100. </template>
  101. <script>
  102. import { commonMixin } from '@/utils/mixin'
  103. import { STable, VSelect } from '@/components'
  104. import inventoryCheckAddModal from './addModal.vue'
  105. import commonModal from '@/views/common/commonModal.vue'
  106. import warehouse from '@/views/common/chooseWarehouse.js'
  107. import { checkWarehouseList, checkWarehouseStartCheck } from '@/api/checkWarehouse'
  108. export default {
  109. name: 'InventoryCheckList',
  110. mixins: [commonMixin],
  111. components: { STable, VSelect, inventoryCheckAddModal, commonModal, warehouse },
  112. data () {
  113. return {
  114. spinning: false,
  115. tableHeight: 0,
  116. queryParam: { // 查询条件
  117. deleteFlag: this.$route.params.type,
  118. checkWarehouseNo: '',
  119. checkState: undefined,
  120. warehouseSn: undefined,
  121. checkSuperviseState: undefined
  122. },
  123. disabled: false, // 查询、重置按钮是否可操作
  124. tabPaneData: [
  125. { name: '正常', type: '0' },
  126. { name: '已作废', type: '1' }
  127. ],
  128. // 加载数据方法 必须为 Promise 对象
  129. loadData: parameter => {
  130. this.disabled = true
  131. this.spinning = true
  132. return checkWarehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  133. let data
  134. if (res.status == 200) {
  135. data = res.data
  136. const no = (data.pageNo - 1) * data.pageSize
  137. for (var i = 0; i < data.list.length; i++) {
  138. data.list[i].no = no + i + 1
  139. }
  140. this.disabled = false
  141. }
  142. this.spinning = false
  143. return data
  144. })
  145. },
  146. openModal: false,
  147. itemSn: '',
  148. openAddModal: false,
  149. openCommonModal: false,
  150. modalHtml: ''
  151. }
  152. },
  153. computed: {
  154. columns () {
  155. let arr = [
  156. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  157. { title: '盘点单号', dataIndex: 'checkWarehouseNo', width: '10%', align: 'center' },
  158. // { title: '仓库', dataIndex: 'warehouseName', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  159. { title: '盘点状态', dataIndex: 'checkStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  160. { title: '监盘状态', dataIndex: 'checkSuperviseStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  161. { title: '盘点人', dataIndex: 'checkPersonName', align: 'center', width: '8%', customRender: function (text) { return text || '--' }, ellipsis: true },
  162. { title: '盘点提交时间', dataIndex: 'checkTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  163. { title: '监盘人', dataIndex: 'checkSupervisePersonName', align: 'center', width: '8%', customRender: function (text) { return text || '--' }, ellipsis: true },
  164. { title: '监盘提交时间', dataIndex: 'checkSuperviseTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  165. ]
  166. if (this.queryParam.deleteFlag == '0') { // 正常
  167. arr = arr.concat([
  168. { title: '财务确认时间', dataIndex: 'financeAuditTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '盘点单创建时间', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  170. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  171. ])
  172. } else if (this.queryParam.deleteFlag == '1') { // 已作废
  173. arr = arr.concat([
  174. { title: '盘点单创建时间', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  175. { title: '盘点单作废时间', dataIndex: 'deleteTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  176. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  177. ])
  178. }
  179. if(this.isShowWarehouse){
  180. arr.splice(2,0,{ title: '仓库', dataIndex: 'warehouseName', width: '12%', align: 'center', customRender: function (text) { return text || '--' } })
  181. }
  182. return arr
  183. }
  184. },
  185. methods: {
  186. // 新增
  187. handleAdd () {
  188. this.spinning = true
  189. checkWarehouseStartCheck({}).then(res => {
  190. this.spinning = false
  191. if (res.status == 200) {
  192. if (res.data && res.data.length > 0) {
  193. // this.modalHtml = `<div style="width: 100%">
  194. // <h3 style="font-size: 15px;font-weight: bold;margin: 20px 0 5px;text-align: center;">存在以下状态的销售单,无法盘点。</h3>
  195. // <h3 style="font-size: 15px;font-weight: bold;margin-bottom: 25px;text-align: center;">请先检查并处理完以下单据再试。</h3>
  196. // ${res.data.indexOf('WAIT_AUDIT') != -1 ? '<p>销售单-待审核(总部自建)</p>' : ''}
  197. // ${res.data.indexOf('AUDIT_REJECT') != -1 ? '<p>销售单-审核不通过(总部自建)</p>' : ''}
  198. // ${res.data.indexOf('HQ_CHANGE') != -1 ? '<p>销售单-总公司改单</p>' : ''}
  199. // ${res.data.indexOf('WAIT_PUSH') != -1 ? '<p>销售单-待下推</p>' : ''}
  200. // </div>`
  201. this.modalHtml = `<div style="width: 100%">
  202. ${res.data.indexOf('WAIT_PUSH') != -1 ? '<p>存在“待下推”状态的销售单,无法盘点。</p>' : ''}
  203. </div>`
  204. this.openCommonModal = true
  205. } else {
  206. this.openAddModal = true
  207. }
  208. }
  209. })
  210. },
  211. // 新增 成功
  212. handleAddOk (data) {
  213. this.$router.push({ path: `/inventoryManagement/inventoryCheck/detail/${data.checkWarehouseSn}` })
  214. },
  215. // 选择类型
  216. handleTabChange (key) {
  217. this.queryParam.deleteFlag = key
  218. this.$refs.table.refresh(true)
  219. },
  220. // 详情
  221. handleDetail (row) {
  222. if (this.$hasPermissions('B_inventoryCheckDetail')) {
  223. this.$router.push({ path: `/inventoryManagement/inventoryCheck/detail/${row.checkWarehouseSn}` })
  224. }
  225. },
  226. resetSearchForm () {
  227. this.queryParam.checkWarehouseNo = ''
  228. this.queryParam.checkState = undefined
  229. this.queryParam.checkSuperviseState = undefined
  230. this.$refs.table.refresh(true)
  231. },
  232. closeModal () {
  233. this.itemSn = ''
  234. this.openModal = false
  235. },
  236. pageInit () {
  237. const _this = this
  238. this.$nextTick(() => { // 页面渲染完成后的回调
  239. _this.setTableH()
  240. })
  241. },
  242. setTableH () {
  243. this.tableHeight = window.innerHeight - 332
  244. }
  245. },
  246. watch: {
  247. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  248. this.setTableH()
  249. }
  250. },
  251. mounted () {
  252. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  253. this.pageInit()
  254. this.$refs.table.refresh(true)
  255. }
  256. },
  257. activated () {
  258. // 如果是新页签打开,则重置当前页面
  259. if (this.$store.state.app.isNewTab) {
  260. this.pageInit()
  261. this.$refs.table.refresh(true)
  262. }
  263. // 仅刷新列表,不重置页面
  264. if (this.$store.state.app.updateList) {
  265. this.pageInit()
  266. this.$refs.table.refresh()
  267. }
  268. },
  269. beforeRouteEnter (to, from, next) {
  270. next(vm => {
  271. const _this = vm
  272. if (_this.$route.params.type == '1') {
  273. setTimeout(() => {
  274. _this.$refs.table.refresh(true)
  275. }, 300)
  276. }
  277. })
  278. }
  279. }
  280. </script>
  281. <style lang="less">
  282. .inventoryCheckList-wrap{
  283. .active{
  284. color: #ed1c24;
  285. cursor: pointer;
  286. }
  287. .common{
  288. color: rgba(0, 0, 0);
  289. }
  290. // tab样式
  291. .inventoryCheckList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-nav-container{
  292. height: 30px!important;
  293. }
  294. .inventoryCheckList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab-active{
  295. height: 30px!important;
  296. }
  297. .inventoryCheckList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab{
  298. line-height: 26px!important;
  299. height: 30px!important;
  300. }
  301. }
  302. </style>