list.vue 10 KB

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