list.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <a-card size="small" :bordered="false" class="satelliteWarehouseInventoryList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form-model
  7. id="satelliteWarehouseInventoryList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. :labelCol="labelCol"
  14. :wrapperCol="wrapperCol"
  15. @keyup.enter.native="handleSearch" >
  16. <a-row :gutter="15">
  17. <a-col :md="6" :sm="24">
  18. <a-form-model-item label="客户名称" prop="customer.customerSn">
  19. <custSatelliteList ref="custSatelliteList" :verify="true" @change="custSatelliteChange"></custSatelliteList>
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-model-item label="配件名称">
  24. <a-input id="satelliteWarehouseInventoryList-name" v-model.trim="queryParam.dealerProduct.name" allowClear placeholder="请输入配件名称" />
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-model-item label="配件编码">
  29. <a-input id="satelliteWarehouseInventoryList-queryWord" v-model.trim="queryParam.dealerProduct.queryWord" allowClear placeholder="请输入产品编码或产品原厂编码" />
  30. </a-form-model-item>
  31. </a-col>
  32. <a-col :md="6" :sm="24">
  33. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="satelliteWarehouseInventoryList-refresh">查询</a-button>
  34. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="satelliteWarehouseInventoryList-reset">重置</a-button>
  35. </a-col>
  36. </a-row>
  37. </a-form-model>
  38. </div>
  39. <!-- 操作按钮 -->
  40. <div class="table-operator">
  41. <a-button v-if="$hasPermissions('B_satelliteWarehouseInventoryDetail')" id="satelliteWarehouseInventoryList-replenishment" type="primary" class="button-error" @click="handleReplenishment">补货清单</a-button>
  42. </div>
  43. <!-- 列表 -->
  44. <s-table
  45. class="sTable fixPagination"
  46. ref="table"
  47. :style="{ height: tableHeight+84.5+'px' }"
  48. size="small"
  49. :rowKey="(record) => record.id"
  50. :columns="columns"
  51. :data="loadData"
  52. :defaultLoadData="false"
  53. :scroll="{ x: 1210, y: tableHeight }"
  54. bordered>
  55. <!-- 操作 -->
  56. <template slot="action" slot-scope="text, record">
  57. <a-button size="small" v-if="$hasPermissions('B_satelliteWarehouseInventoryAdd')" type="link" @click="handleAdd(record)" id="satelliteWarehouseInventoryList-add-btn">加入补货单</a-button>
  58. <span v-if="!$hasPermissions('B_satelliteWarehouseInventoryAdd')">--</span>
  59. </template>
  60. </s-table>
  61. </a-spin>
  62. <!-- 补货单 -->
  63. <satellite-warehouse-inventory-add-modal :openModal="openModal" :nowData="nowData" @close="closeModal" />
  64. </a-card>
  65. </template>
  66. <script>
  67. import { STable, VSelect } from '@/components'
  68. import satelliteWarehouseInventoryAddModal from './addModal.vue'
  69. import custSatelliteList from '@/views/common/custSatelliteList.vue'
  70. import { satelliteWHStockList, satelliteWHSupplyInsert } from '@/api/satelliteWH'
  71. export default {
  72. components: { STable, VSelect, satelliteWarehouseInventoryAddModal, custSatelliteList },
  73. data () {
  74. return {
  75. spinning: false,
  76. labelCol: { span: 8 },
  77. wrapperCol: { span: 16 },
  78. tableHeight: 0,
  79. queryParam: {
  80. customer: {
  81. customerSn: undefined
  82. },
  83. dealerProduct: {
  84. name: '',
  85. queryWord: ''
  86. }
  87. },
  88. rules: {
  89. 'customer.customerSn': [{ required: true, message: '请选择客户名称', trigger: ['blur', 'change'] }]
  90. },
  91. disabled: false, // 查询、重置按钮是否可操作
  92. loading: false, // 表格加载中
  93. columns: [
  94. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  95. { title: '客户名称', dataIndex: 'customer.customerName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  96. { title: '配件名称', dataIndex: 'dealerProduct.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  97. { title: '产品编码', dataIndex: 'dealerProduct.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  98. { title: '原厂编码', dataIndex: 'dealerProduct.origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  99. { title: '当前库存', dataIndex: 'currentStockQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  100. { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
  101. ],
  102. // 加载数据方法 必须为 Promise 对象
  103. loadData: parameter => {
  104. this.disabled = true
  105. this.spinning = true
  106. return satelliteWHStockList(Object.assign(parameter, this.queryParam)).then(res => {
  107. const data = res.data
  108. const no = (data.pageNo - 1) * data.pageSize
  109. for (var i = 0; i < data.list.length; i++) {
  110. data.list[i].no = no + i + 1
  111. }
  112. this.disabled = false
  113. this.spinning = false
  114. return data
  115. })
  116. },
  117. openModal: false,
  118. nowData: null
  119. }
  120. },
  121. methods: {
  122. custSatelliteChange (val) {
  123. this.queryParam.customer.customerSn = val.key
  124. this.nowData = {
  125. customerName: '',
  126. customerSn: ''
  127. }
  128. this.nowData.customerName = val.label
  129. this.nowData.customerSn = val.key
  130. },
  131. // 查询
  132. handleSearch () {
  133. this.$refs.ruleForm.validate(valid => {
  134. if (valid) {
  135. this.$refs.table.refresh(true)
  136. } else {
  137. console.log('error submit!!')
  138. return false
  139. }
  140. })
  141. },
  142. // 重置
  143. resetSearchForm () {
  144. this.queryParam.customer.customerSn = undefined
  145. this.queryParam.dealerProduct.name = ''
  146. this.queryParam.dealerProduct.queryWord = ''
  147. this.$refs.custSatelliteList.resetForm()
  148. this.nowData = null
  149. this.$refs.ruleForm.resetFields()
  150. this.$refs.table.clearTable()
  151. },
  152. // 补货清单
  153. handleReplenishment () {
  154. this.$refs.ruleForm.validate(valid => {
  155. if (valid) {
  156. this.openModal = true
  157. } else {
  158. console.log('error submit!!')
  159. return false
  160. }
  161. })
  162. },
  163. // 加入补货单
  164. handleAdd (row) {
  165. const params = {
  166. sn: row.customerSn,
  167. satelliteWarehouseSupply: {
  168. productSn: row.dealerProduct.productSn,
  169. productCode: row.dealerProduct.code,
  170. productQty: 1
  171. }
  172. }
  173. this.spinning = true
  174. satelliteWHSupplyInsert(params).then(res => {
  175. if (res.status == 200) {
  176. this.$message.success('添加成功')
  177. this.spinning = false
  178. } else {
  179. this.spinning = false
  180. }
  181. })
  182. },
  183. // 关闭弹框
  184. closeModal () {
  185. this.openModal = false
  186. },
  187. pageInit () {
  188. const _this = this
  189. this.$nextTick(() => { // 页面渲染完成后的回调
  190. _this.setTableH()
  191. })
  192. },
  193. setTableH () {
  194. const tableSearchH = this.$refs.tableSearch.offsetHeight
  195. this.tableHeight = window.innerHeight - tableSearchH - 235
  196. }
  197. },
  198. watch: {
  199. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  200. this.setTableH()
  201. }
  202. },
  203. mounted () {
  204. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  205. this.pageInit()
  206. this.resetSearchForm()
  207. }
  208. },
  209. activated () {
  210. // 如果是新页签打开,则重置当前页面
  211. if (this.$store.state.app.isNewTab) {
  212. this.pageInit()
  213. this.resetSearchForm()
  214. }
  215. },
  216. beforeRouteEnter (to, from, next) {
  217. next(vm => {})
  218. }
  219. }
  220. </script>