list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <a-card :bordered="false" class="inventoryWarningList-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="inventoryWarningList-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="inventoryWarningList-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="inventoryWarningList-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="inventoryWarningList-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="预警提示">
  37. <a-select id="inventoryWarningList-bundleNames" placeholder="请选择预警提示" allowClear v-model="queryParam.brand">
  38. <a-select-option v-for="item in brandData" :key="item.stationNo" :value="item.stationNo">{{ item.name }}</a-select-option>
  39. </a-select>
  40. </a-form-item>
  41. </a-col>
  42. </template>
  43. <a-col :md="6" :sm="24">
  44. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryWarningList-refresh">查询</a-button>
  45. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="inventoryWarningList-reset">重置</a-button>
  46. <a-button style="margin-left: 8px" type="danger" @click="handleExport" :disabled="disabled" :loading="exportLoading" id="inventoryWarningList-export">导出</a-button>
  47. <a @click="advanced=!advanced" style="margin-left: 8px">
  48. {{ advanced ? '收起' : '展开' }}
  49. <a-icon :type="advanced ? 'up' : 'down'"/>
  50. </a>
  51. </a-col>
  52. </a-row>
  53. </a-form>
  54. </div>
  55. <!-- 操作按钮 -->
  56. <div class="table-operator">
  57. <a-button id="inventoryWarningList-update" type="primary" @click="handleupdate">批量更新</a-button>
  58. </div>
  59. <!-- 列表 -->
  60. <s-table
  61. class="sTable"
  62. ref="table"
  63. size="default"
  64. :rowKey="(record) => record.id"
  65. :columns="columns"
  66. :data="loadData"
  67. bordered>
  68. <!-- 需要编辑的字段 -->
  69. <template
  70. v-for="col in ['onWayNum', 'maxInventory', 'minInventory']"
  71. :slot="col"
  72. slot-scope="text, record, index"
  73. >
  74. <div :key="col">
  75. <a-input
  76. v-if="record.editable"
  77. style="margin: -5px 0"
  78. :value="text"
  79. @change="e => handleChange(e.target.value, record.key, col)"
  80. />
  81. <template v-else>
  82. {{ text }}
  83. </template>
  84. </div>
  85. </template>
  86. <!-- 操作 -->
  87. <template slot="action" slot-scope="text, record">
  88. <div class="editable-row-operations">
  89. <span v-if="record.editable">
  90. <a @click="() => save(record.key)">保存</a>
  91. <a-popconfirm title="Sure to cancel?" @confirm="() => cancel(record.key)">
  92. <a>取消</a>
  93. </a-popconfirm>
  94. </span>
  95. <span v-else>
  96. <a :disabled="editingKey !== ''" @click="() => edit(record.key)">编辑</a>
  97. </span>
  98. </div>
  99. </template>
  100. </s-table>
  101. </a-card>
  102. </template>
  103. <script>
  104. import moment from 'moment'
  105. // import { customerBundleDelayList, customerBundleExportDelay } from '@/api/FinancialManagement'
  106. import { STable } from '@/components'
  107. export default {
  108. components: { STable },
  109. data () {
  110. return {
  111. advanced: false, // 高级搜索 展开/关闭
  112. queryParam: { // 查询条件
  113. orderBundleNo: '', // 订单编号
  114. orderBundle: {
  115. custMobile: '' // 客户手机
  116. },
  117. bundleName: '', // 套餐名称
  118. itemName: '', // 服务名称
  119. brand: undefined, // 产品品牌
  120. inventoryNum: false // 库存数量是否为0
  121. },
  122. exportLoading: false, // 导出loading
  123. disabled: false, // 查询、重置按钮是否可操作
  124. brandData: [], // 产品品牌下拉数据
  125. typeData: [], // 产品类别下拉数据
  126. columns: [
  127. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  128. { title: '产品编码', dataIndex: 'productNum', width: 160, align: 'center' },
  129. { title: '产品名称', dataIndex: 'productName', width: 200, align: 'center', ellipsis: true },
  130. { title: '级别', dataIndex: 'productNasme', width: 100, align: 'center' },
  131. { title: '原厂编码', dataIndex: 'productOldNum', width: 160, align: 'center' },
  132. { title: '产品品牌', dataIndex: 'productBrand', width: 200, align: 'center' },
  133. { title: '产品分类', dataIndex: 'productType', width: 200, align: 'center' },
  134. { title: '实时库存数(个)', dataIndex: 'inventoryNumy', width: 180, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  135. { title: '在途数(个)', scopedSlots: { customRender: 'onWayNum' }, width: 180, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  136. { title: '总库存数(个)', dataIndex: 'inventoryNumw', width: 180, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  137. { title: '最大库存数(个)', scopedSlots: { customRender: 'maxInventory' }, width: 180, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  138. { title: '最小库存数(个)', scopedSlots: { customRender: 'minInventory' }, width: 180, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  139. { title: '差异数量', dataIndex: 'inventoryNumh', width: 180, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  140. { title: '预警提示', dataIndex: 'inventoryNum', width: 180, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  141. { title: '操作', scopedSlots: { customRender: 'action' }, width: 240, align: 'center' }
  142. ],
  143. // 加载数据方法 必须为 Promise 对象
  144. loadData: parameter => {
  145. this.disabled = true
  146. // return customerBundleDelayList( Object.assign(parameter, this.queryParam) ).then(res => {
  147. // const data = res.data
  148. // const no = (data.pageNo - 1) * data.pageSize
  149. // for (var i = 0; i < data.list.length; i++) {
  150. // data.list[i].no = no + i + 1
  151. // }
  152. // this.disabled = false
  153. // return data
  154. // })
  155. const _this = this
  156. return new Promise(function(resolve, reject){
  157. const data = {
  158. pageNo: 1,
  159. pageSize: 10,
  160. list: [
  161. { id: '1', productNum: 'jgqp11111111111', productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', productType: '产品分类1', inventoryNum: '5', inventoryMoney: '122' }
  162. ]
  163. }
  164. const no = (data.pageNo - 1) * data.pageSize
  165. for (var i = 0; i < data.list.length; i++) {
  166. data.list[i].no = no + i + 1
  167. }
  168. _this.disabled = false
  169. resolve(data)
  170. })
  171. },
  172. openModal: false, // 查看库存详情 弹框
  173. itemId: '', // 当前库存记录id
  174. editingKey: ''
  175. }
  176. },
  177. methods: {
  178. // 重置
  179. resetSearchForm () {
  180. this.queryParam.orderBundleNo = ''
  181. this.queryParam.orderBundle.custMobile = ''
  182. this.queryParam.bundleName = ''
  183. this.queryParam.itemName = ''
  184. this.oldTime = undefined
  185. this.newTime = undefined
  186. this.$refs.table.refresh(true)
  187. },
  188. // 批量更新
  189. handleupdate(){
  190. const _this = this
  191. this.$confirm({
  192. title: '提示',
  193. content: '确定提交批量更新的内容吗?',
  194. okText: '确定',
  195. cancelText: '取消',
  196. onOk () {
  197. // delectRolePower({
  198. // id: row.id
  199. // }).then(res => {
  200. // console.log(res, 'res1111')
  201. // if (res.status == 200) {
  202. // _this.$message.success(res.message)
  203. // _this.$refs.table.refresh()
  204. // }
  205. // })
  206. }
  207. })
  208. },
  209. handleChange(value, key, column) {
  210. const newData = [...this.data];
  211. const target = newData.filter(item => key === item.key)[0];
  212. if (target) {
  213. target[column] = value;
  214. this.data = newData;
  215. }
  216. },
  217. edit(key) {
  218. const newData = [...this.data];
  219. const target = newData.filter(item => key === item.key)[0];
  220. this.editingKey = key;
  221. if (target) {
  222. target.editable = true;
  223. this.data = newData;
  224. }
  225. },
  226. save(key) {
  227. const newData = [...this.data];
  228. const newCacheData = [...this.cacheData];
  229. const target = newData.filter(item => key === item.key)[0];
  230. const targetCache = newCacheData.filter(item => key === item.key)[0];
  231. if (target && targetCache) {
  232. delete target.editable;
  233. this.data = newData;
  234. Object.assign(targetCache, target);
  235. this.cacheData = newCacheData;
  236. }
  237. this.editingKey = '';
  238. },
  239. cancel(key) {
  240. const newData = [...this.data];
  241. const target = newData.filter(item => key === item.key)[0];
  242. this.editingKey = '';
  243. if (target) {
  244. Object.assign(target, this.cacheData.filter(item => key === item.key)[0]);
  245. delete target.editable;
  246. this.data = newData;
  247. }
  248. },
  249. // 导出
  250. handleExport () {
  251. const params = this.queryParam
  252. this.exportLoading = true
  253. customerBundleExportDelay(params).then(res => {
  254. this.exportLoading = false
  255. this.download(res)
  256. })
  257. },
  258. download (data) {
  259. if (!data) { return }
  260. const url = window.URL.createObjectURL(new Blob([data]))
  261. const link = document.createElement('a')
  262. link.style.display = 'none'
  263. link.href = url
  264. const a = moment().format('YYYYMMDDHHmmss')
  265. const fname = '库存预警' + a
  266. link.setAttribute('download', fname + '.xlsx')
  267. document.body.appendChild(link)
  268. link.click()
  269. }
  270. }
  271. }
  272. </script>
  273. <style lang="less">
  274. .inventoryWarningList-wrap{
  275. .sTable{
  276. table{
  277. width: auto;
  278. }
  279. }
  280. }
  281. </style>