list.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <a-card :bordered="false" class="inventoryQueryList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="产品编码">
  9. <a-input id="inventoryQueryList-orderBundleNo" v-model.trim="queryParam.orderBundleNo" allowClear placeholder="请输入产品编码"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="原厂编码">
  14. <a-input id="inventoryQueryList-custMobile" v-model.trim="queryParam.orderBundle.custMobile" allowClear placeholder="请输入原厂编码"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="产品名称">
  19. <a-input id="inventoryQueryList-bundleName" v-model.trim="queryParam.bundleName" allowClear placeholder="请输入产品名称"/>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="产品品牌">
  25. <a-select id="inventoryQueryList-bundleNames" placeholder="请选择产品品牌" allowClear v-model="queryParam.brand">
  26. <a-select-option v-for="item in brandData" :key="item.stationNo" :value="item.stationNo">{{ item.name }}</a-select-option>
  27. </a-select>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="产品类别">
  32. <a-cascader :options="typeData" placeholder="请选择产品类别" allowClear v-model="queryParam.brand" />
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24">
  36. <a-form-item label="库存数量是否为0">
  37. <a-switch checkedChildren="是" unCheckedChildren="否" id="inventoryQueryList-bundleNamess" v-model="queryParam.inventoryNum" />
  38. </a-form-item>
  39. </a-col>
  40. </template>
  41. <a-col :md="6" :sm="24">
  42. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryQueryList-refresh">查询</a-button>
  43. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="inventoryQueryList-reset">重置</a-button>
  44. <a-button style="margin-left: 8px" type="danger" @click="handleExport" :disabled="disabled" :loading="exportLoading" id="inventoryQueryList-export">导出</a-button>
  45. <a @click="advanced=!advanced" style="margin-left: 8px">
  46. {{ advanced ? '收起' : '展开' }}
  47. <a-icon :type="advanced ? 'up' : 'down'"/>
  48. </a>
  49. </a-col>
  50. </a-row>
  51. </a-form>
  52. </div>
  53. <!-- 合计 -->
  54. <a-alert type="info" showIcon style="margin-bottom:15px">
  55. <div class="ftext" slot="message">现有库存总数量(个):<strong>998</strong>;现有库存总成本(¥):<strong>2009.00</strong>。</div>
  56. </a-alert>
  57. <!-- 列表 -->
  58. <s-table
  59. class="sTable"
  60. ref="table"
  61. size="default"
  62. :rowKey="(record) => record.id"
  63. :columns="columns"
  64. :data="loadData"
  65. bordered>
  66. <!-- 操作 -->
  67. <template slot="action" slot-scope="text, record">
  68. <a-button type="primary" @click="goDetail(record)" id="inventoryQueryList-detail-btn" style="margin: 0 0 8px 0;">库存详情</a-button>
  69. <a-button style="margin-left: 8px" @click="goWarehouseDetail(record)" id="inventoryQueryList-warehouseDetail-btn">出入库明细</a-button>
  70. </template>
  71. </s-table>
  72. <!-- 库存详情 -->
  73. <inventory-query-detail-modal :openModal="openModal" :itemId="itemId" @close="closeModal" />
  74. </a-card>
  75. </template>
  76. <script>
  77. import moment from 'moment'
  78. // import { customerBundleDelayList, customerBundleExportDelay } from '@/api/FinancialManagement'
  79. import { STable } from '@/components'
  80. import inventoryQueryDetailModal from './detailModal.vue'
  81. export default {
  82. components: { STable, inventoryQueryDetailModal },
  83. data () {
  84. return {
  85. advanced: false, // 高级搜索 展开/关闭
  86. queryParam: { // 查询条件
  87. orderBundleNo: '', // 订单编号
  88. orderBundle: {
  89. custMobile: '' // 客户手机
  90. },
  91. bundleName: '', // 套餐名称
  92. itemName: '', // 服务名称
  93. brand: undefined, // 产品品牌
  94. inventoryNum: false // 库存数量是否为0
  95. },
  96. exportLoading: false, // 导出loading
  97. disabled: false, // 查询、重置按钮是否可操作
  98. brandData: [], // 产品品牌下拉数据
  99. typeData: [], // 产品类别下拉数据
  100. columns: [
  101. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  102. { title: '产品编码', dataIndex: 'productNum', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  103. { title: '产品名称', dataIndex: 'productName', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  104. { title: '原厂编码', dataIndex: 'productOldNum', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  105. { title: '产品品牌', dataIndex: 'productBrand', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: '产品分类', dataIndex: 'productType', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  107. { title: '现有库存数量(个)', dataIndex: 'inventoryNum', width: 180, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  108. { title: '现有库存成本(¥)', dataIndex: 'inventoryMoney', width: 180, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  109. { title: '操作', scopedSlots: { customRender: 'action' }, width: 240, align: 'center' }
  110. ],
  111. // 加载数据方法 必须为 Promise 对象
  112. loadData: parameter => {
  113. this.disabled = true
  114. // return customerBundleDelayList( Object.assign(parameter, this.queryParam) ).then(res => {
  115. // const data = res.data
  116. // const no = (data.pageNo - 1) * data.pageSize
  117. // for (var i = 0; i < data.list.length; i++) {
  118. // data.list[i].no = no + i + 1
  119. // }
  120. // this.disabled = false
  121. // return data
  122. // })
  123. const _this = this
  124. return new Promise(function(resolve, reject){
  125. const data = {
  126. pageNo: 1,
  127. pageSize: 10,
  128. list: [
  129. { id: '1', productNum: 'jgqp11111111111', productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', productType: '产品分类1', inventoryNum: '5', inventoryMoney: '122' }
  130. ]
  131. }
  132. const no = (data.pageNo - 1) * data.pageSize
  133. for (var i = 0; i < data.list.length; i++) {
  134. data.list[i].no = no + i + 1
  135. }
  136. _this.disabled = false
  137. resolve(data)
  138. })
  139. },
  140. openModal: false, // 查看库存详情 弹框
  141. itemId: '' // 当前库存记录id
  142. }
  143. },
  144. methods: {
  145. // 重置
  146. resetSearchForm () {
  147. this.queryParam.orderBundleNo = ''
  148. this.queryParam.orderBundle.custMobile = ''
  149. this.queryParam.bundleName = ''
  150. this.queryParam.itemName = ''
  151. this.oldTime = undefined
  152. this.newTime = undefined
  153. this.$refs.table.refresh(true)
  154. },
  155. // 库存详情
  156. goDetail(row){
  157. this.itemId = row.id
  158. this.openModal = true
  159. },
  160. // 关闭弹框
  161. closeModal(){
  162. this.itemId = ''
  163. this.openModal = false
  164. },
  165. // 出入库明细
  166. goWarehouseDetail(row){
  167. this.$router.push({ path: `/inventoryManagement/inventoryQuery/warehouseDetail/${row.id}` })
  168. },
  169. // 导出
  170. handleExport () {
  171. const params = this.queryParam
  172. if (this.oldTime && this.oldTime.length > 0) {
  173. params.beginOldExpiryDate = moment(this.oldTime[0]).format('YYYY-MM-DD')
  174. params.endOldExpirydDate = moment(this.oldTime[1]).format('YYYY-MM-DD')
  175. } else {
  176. params.beginOldExpiryDate = ''
  177. params.endOldExpirydDate = ''
  178. }
  179. if (this.newTime && this.newTime.length > 0) {
  180. params.beginDate = moment(this.newTime[0]).format('YYYY-MM-DD')
  181. params.endDate = moment(this.newTime[1]).format('YYYY-MM-DD')
  182. } else {
  183. params.beginDate = ''
  184. params.endDate = ''
  185. }
  186. this.exportLoading = true
  187. customerBundleExportDelay(params).then(res => {
  188. this.exportLoading = false
  189. this.download(res)
  190. })
  191. },
  192. download (data) {
  193. if (!data) { return }
  194. const url = window.URL.createObjectURL(new Blob([data]))
  195. const link = document.createElement('a')
  196. link.style.display = 'none'
  197. link.href = url
  198. const a = moment().format('YYYYMMDDHHmmss')
  199. const fname = '库存查询' + a
  200. link.setAttribute('download', fname + '.xlsx')
  201. document.body.appendChild(link)
  202. link.click()
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="less">
  208. .inventoryQueryList-wrap{
  209. .sTable{
  210. table{
  211. width: auto;
  212. }
  213. }
  214. }
  215. </style>