list.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <a-card size="small" :bordered="false" class="satelliteWarehouseInventory-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form-model
  7. id="satelliteWarehouseInventory-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 id="satelliteWarehouseInventory-custname" 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="satelliteWarehouseInventory-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="satelliteWarehouseInventory-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="satelliteWarehouseInventory-refresh">查询</a-button>
  34. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="satelliteWarehouseInventory-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="satelliteWarehouseInventory-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="'satelliteWarehouseInventory-add-'+record.id">加入补货单</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 { commonMixin } from '@/utils/mixin'
  68. import { STable, VSelect } from '@/components'
  69. import satelliteWarehouseInventoryAddModal from './addModal.vue'
  70. import custSatelliteList from '@/views/common/custSatelliteList.vue'
  71. import { satelliteWHStockList, satelliteWHSupplyInsert } from '@/api/satelliteWH'
  72. export default {
  73. name: 'SatelliteWHStockList',
  74. components: { STable, VSelect, satelliteWarehouseInventoryAddModal, custSatelliteList },
  75. mixins: [commonMixin],
  76. data () {
  77. return {
  78. spinning: false,
  79. labelCol: { span: 8 },
  80. wrapperCol: { span: 16 },
  81. tableHeight: 0,
  82. queryParam: {
  83. customer: {
  84. customerSn: undefined // 客户
  85. },
  86. dealerProduct: { // 产品信息
  87. name: '', // 产品名称
  88. queryWord: '' // 产品编码或原厂编码
  89. }
  90. },
  91. rules: {
  92. 'customer.customerSn': [{ required: true, message: '请选择客户名称', trigger: ['blur', 'change'] }]
  93. },
  94. disabled: false, // 查询、重置按钮是否可操作
  95. loading: false, // 表格加载中
  96. columns: [
  97. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  98. { title: '客户名称', dataIndex: 'customer.customerName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  99. { title: '配件名称', dataIndex: 'dealerProduct.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  100. { title: '产品编码', dataIndex: 'dealerProduct.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  101. { title: '原厂编码', dataIndex: 'dealerProduct.origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  102. { title: '当前库存', dataIndex: 'currentStockQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  103. { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
  104. ],
  105. // 加载数据方法 必须为 Promise 对象
  106. loadData: parameter => {
  107. this.disabled = true
  108. this.spinning = true
  109. return satelliteWHStockList(Object.assign(parameter, this.queryParam)).then(res => {
  110. let data
  111. if (res.status == 200) {
  112. data = res.data
  113. const no = (data.pageNo - 1) * data.pageSize
  114. for (var i = 0; i < data.list.length; i++) {
  115. data.list[i].no = no + i + 1
  116. }
  117. this.disabled = false
  118. }
  119. this.spinning = false
  120. return data
  121. })
  122. },
  123. openModal: false, // 打开补货单弹框
  124. nowData: null // 当前操作数据
  125. }
  126. },
  127. methods: {
  128. // 选择客户名称
  129. custSatelliteChange (val) {
  130. this.queryParam.customer.customerSn = val.key
  131. this.nowData = {
  132. customerName: '',
  133. customerSn: ''
  134. }
  135. this.nowData.customerName = val.label
  136. this.nowData.customerSn = val.key
  137. },
  138. // 查询
  139. handleSearch () {
  140. this.$refs.ruleForm.validate(valid => {
  141. if (valid) {
  142. this.$refs.table.refresh(true)
  143. } else {
  144. console.log('error submit!!')
  145. return false
  146. }
  147. })
  148. },
  149. // 重置
  150. resetSearchForm () {
  151. this.queryParam.customer.customerSn = undefined
  152. this.queryParam.dealerProduct.name = ''
  153. this.queryParam.dealerProduct.queryWord = ''
  154. this.$refs.custSatelliteList.resetForm()
  155. this.nowData = null
  156. this.$refs.ruleForm.resetFields()
  157. this.$refs.table.clearTable()
  158. },
  159. // 补货清单
  160. handleReplenishment () {
  161. this.$refs.ruleForm.validate(valid => {
  162. if (valid) {
  163. this.openModal = true
  164. } else {
  165. console.log('error submit!!')
  166. return false
  167. }
  168. })
  169. },
  170. // 加入补货单
  171. handleAdd (row) {
  172. const params = {
  173. sn: row.customerSn,
  174. satelliteWarehouseSupply: {
  175. productSn: row.dealerProduct.productSn,
  176. productCode: row.dealerProduct.code,
  177. productQty: 1
  178. }
  179. }
  180. this.spinning = true
  181. satelliteWHSupplyInsert(params).then(res => {
  182. if (res.status == 200) {
  183. this.$message.success('添加成功')
  184. this.spinning = false
  185. } else {
  186. this.spinning = false
  187. }
  188. })
  189. },
  190. // 关闭弹框
  191. closeModal () {
  192. this.openModal = false
  193. },
  194. // 页面初始化
  195. pageInit () {
  196. const _this = this
  197. this.$nextTick(() => { // 页面渲染完成后的回调
  198. _this.setTableH()
  199. })
  200. },
  201. // 表格高度
  202. setTableH () {
  203. const tableSearchH = this.$refs.tableSearch.offsetHeight
  204. this.tableHeight = window.innerHeight - tableSearchH - 235
  205. }
  206. },
  207. watch: {
  208. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  209. this.setTableH()
  210. }
  211. },
  212. mounted () {
  213. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  214. this.pageInit()
  215. this.resetSearchForm()
  216. }
  217. },
  218. activated () {
  219. // 如果是新页签打开,则重置当前页面
  220. if (this.$store.state.app.isNewTab) {
  221. this.pageInit()
  222. this.resetSearchForm()
  223. }
  224. },
  225. beforeRouteEnter (to, from, next) {
  226. next(vm => {})
  227. }
  228. }
  229. </script>