list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <a-card size="small" :bordered="false" class="allocationDetailsList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="allocationDetailsList-form"
  8. ref="ruleForm"
  9. :model="queryParam"
  10. :rules="rules"
  11. :labelCol="labelCol"
  12. :wrapperCol="wrapperCol"
  13. @keyup.enter.native="handleSearch" >
  14. <a-row :gutter="15">
  15. <a-col :md="6" :sm="24">
  16. <a-form-model-item label="调拨开单日期" prop="time">
  17. <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
  18. </a-form-model-item>
  19. </a-col>
  20. <a-col :md="5" :sm="24">
  21. <a-form-model-item label="产品名称">
  22. <a-input id="allocationDetailsList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="5" :sm="24">
  26. <a-form-model-item label="品牌分类">
  27. <v-select code="BRAND_TYPE" id="allocationDetailsList-productBrandTypeSn" v-model="queryParam.productBrandTypeSn" allowClear placeholder="请选择品牌分类"></v-select>
  28. </a-form-model-item>
  29. </a-col>
  30. <template v-if="advanced">
  31. <a-col :md="7" :sm="24">
  32. <a-form-model-item label="产品品牌">
  33. <a-select
  34. placeholder="请选择"
  35. id="allocationDetailsList-productBrandSn"
  36. allowClear
  37. v-model="queryParam.productBrandSn"
  38. :showSearch="true"
  39. option-filter-prop="children"
  40. :filter-option="filterOption">
  41. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  42. </a-select>
  43. </a-form-model-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24">
  46. <a-form-model-item label="产品编码">
  47. <a-input id="allocationDetailsList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  48. </a-form-model-item>
  49. </a-col>
  50. <a-col :md="6" :sm="24">
  51. <a-form-model-item label="调拨类型名称">
  52. <a-select id="allocationDetailsList-allocateTypeSn" v-model="queryParam.allocateTypeSn" placeholder="请选择调拨类型名称" allowClear >
  53. <a-select-option v-for="item in allocateTypeList" :key="item.allocateTypeSn" :value="item.allocateTypeSn">{{ item.name }}</a-select-option>
  54. </a-select>
  55. </a-form-model-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-model-item label="操作员">
  59. <a-select id="allocationDetailsList-creatorId" v-model="queryParam.creatorId" placeholder="请选择操作员" allowClear >
  60. <a-select-option v-for="item in operatorList" :key="item.sn" :value="item.sn">{{ item.name }}</a-select-option>
  61. </a-select>
  62. </a-form-model-item>
  63. </a-col>
  64. <a-col :md="6" :sm="24">
  65. <a-form-model-item label="调拨单号">
  66. <a-input id="allocationDetailsList-allocateNo" v-model.trim="queryParam.allocateNo" allowClear placeholder="请输入调拨单号"/>
  67. </a-form-model-item>
  68. </a-col>
  69. <a-col :md="6" :sm="24">
  70. <a-form-model-item label="产品分类">
  71. <a-cascader
  72. @change="changeProductType"
  73. expand-trigger="hover"
  74. change-on-select
  75. :options="productTypeList"
  76. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  77. id="allocationDetailsList-productType"
  78. placeholder="请选择产品分类"
  79. allowClear
  80. v-model="productType" />
  81. </a-form-model-item>
  82. </a-col>
  83. <a-col :md="6" :sm="24">
  84. <a-form-model-item label="客户名称">
  85. <a-input id="allocationDetailsList-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入客户名称"/>
  86. </a-form-model-item>
  87. </a-col>
  88. <a-col :md="6" :sm="24">
  89. <a-form-model-item label="客户级别">
  90. <v-select code="DEALER_LEVEL" id="allocationDetailsList-dealerLevel" v-model="queryParam.dealerLevel" allowClear placeholder="请选择客户级别"></v-select>
  91. </a-form-model-item>
  92. </a-col>
  93. <a-col :md="6" :sm="24">
  94. <a-form-model-item label="所在区域">
  95. <subarea id="allocationDetailsList-subarea" v-model="queryParam.subareaSn"></subarea>
  96. </a-form-model-item>
  97. </a-col>
  98. <a-col :md="6" :sm="24">
  99. <a-form-model-item label="地区">
  100. <a-form-model-item prop="dealerProvinceSn">
  101. <a-select id="allocationDetailsList-dealerProvinceSn" v-model="queryParam.dealerProvinceSn" placeholder="请选择省">
  102. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  103. </a-select>
  104. </a-form-model-item>
  105. </a-form-model-item>
  106. </a-col>
  107. </template>
  108. <a-col :md="8" :sm="24" style="margin-top: 3px;">
  109. <a-button
  110. style="margin-bottom: 18px;"
  111. type="primary"
  112. class="button-warning"
  113. size="small"
  114. @click="handleStock"
  115. id="allocationDetailsList-stockDate">盘点区间日期</a-button>
  116. <a-button style="margin: 0 0 18px 8px" type="primary" @click="handleSearch" :disabled="disabled" id="allocationDetailsList-refresh">查询</a-button>
  117. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="allocationDetailsList-reset">重置</a-button>
  118. <a-button
  119. style="margin-left: 5px"
  120. type="primary"
  121. class="button-warning"
  122. @click="handleExport"
  123. :disabled="disabled"
  124. :loading="exportLoading"
  125. id="allocationDetailsList-export">导出</a-button>
  126. <a @click="advanced=!advanced" style="margin-left: 8px">
  127. {{ advanced ? '收起' : '展开' }}
  128. <a-icon :type="advanced ? 'up' : 'down'"/>
  129. </a>
  130. </a-col>
  131. </a-row>
  132. </a-form-model>
  133. </div>
  134. <!-- 列表 -->
  135. <s-table
  136. class="sTable"
  137. ref="table"
  138. size="small"
  139. :rowKey="(record) => record.id"
  140. :columns="columns"
  141. :data="loadData"
  142. :defaultLoadData="false"
  143. :scroll="{ x: 3430 }"
  144. bordered>
  145. <template slot="footer">
  146. <a-row :gutter="15">
  147. <a-col :md="4" :sm="24">
  148. 总数量:{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}
  149. </a-col>
  150. <a-col :md="4" :sm="24">
  151. 总成本价:{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? totalData.totalCost : '--' }}
  152. </a-col>
  153. <a-col :md="4" :sm="24">
  154. 总毛利:{{ (totalData && (totalData.totalGrossProfit || totalData.totalGrossProfit==0)) ? totalData.totalGrossProfit : '--' }}
  155. </a-col>
  156. <a-col :md="4" :sm="24">
  157. 总售价:{{ (totalData && (totalData.totalPrice || totalData.totalPrice==0)) ? totalData.totalPrice : '--' }}
  158. </a-col>
  159. </a-row>
  160. </template>
  161. </s-table>
  162. </a-spin>
  163. </a-card>
  164. </template>
  165. <script>
  166. import moment from 'moment'
  167. import getDate from '@/libs/getDate.js'
  168. import { STable, VSelect } from '@/components'
  169. import rangeDate from '@/views/common/rangeDate.vue'
  170. import subarea from '@/views/common/subarea.js'
  171. import { productBrandQuery } from '@/api/productBrand'
  172. import { productTypeQuery } from '@/api/productType'
  173. import { getArea } from '@/api/data'
  174. import { allocateTypeAllList } from '@/api/allocateType'
  175. import { userQueryList } from '@/api/power-user'
  176. import { allocateReportDetailList, allocateReportDetailCount, allocateReportDetailExport } from '@/api/allocateReport'
  177. export default {
  178. components: { STable, VSelect, rangeDate, subarea },
  179. data () {
  180. return {
  181. spinning: false,
  182. advanced: false, // 高级搜索 展开/关闭
  183. exportLoading: false,
  184. tableHeight: 0,
  185. queryParam: { // 查询条件
  186. time: [
  187. getDate.getCurrMonthDays().starttime,
  188. getDate.getCurrMonthDays().endtime
  189. ],
  190. beginDate: getDate.getCurrMonthDays().starttime,
  191. endDate: getDate.getCurrMonthDays().endtime,
  192. productName: '',
  193. productBrandTypeSn: undefined,
  194. productBrandSn: undefined, // 产品品牌
  195. productCode: '',
  196. allocateTypeSn: undefined, // 调拨类型
  197. creatorId: undefined,
  198. allocateNo: '',
  199. productTypeSn1: '', // 产品一级分类
  200. productTypeSn2: '', // 产品二级分类
  201. productTypeSn3: '', // 产品三级分类
  202. dealerName: '',
  203. dealerLevel: undefined,
  204. subareaSn: undefined,
  205. dealerProvinceSn: undefined
  206. },
  207. productType: [],
  208. labelCol: { span: 8 },
  209. wrapperCol: { span: 16 },
  210. rules: {
  211. 'time': [{ required: true, message: '请选择调拨开单日期', trigger: 'change' }]
  212. },
  213. disabled: false, // 查询、重置按钮是否可操作
  214. columns: [
  215. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  216. { title: '区域', dataIndex: 'subareaNames', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  217. { title: '调拨单号', dataIndex: 'allocateNo', width: 220, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  218. { title: '调拨开单日期', dataIndex: 'allocateDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '省份', dataIndex: 'dealerProvinceName', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  220. { title: '客户名称', dataIndex: 'targetName', align: 'center', sorter: true, customRender: function (text) { return text || '--' }, ellipsis: true },
  221. { title: '客户级别', dataIndex: 'dealerLevelDictValue', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  222. { title: '品牌', dataIndex: 'productBrandName', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  223. { title: '二级分类', dataIndex: 'productTypeName2', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  224. { title: '产品名称', dataIndex: 'productName', align: 'center', sorter: true, customRender: function (text) { return text || '--' }, ellipsis: true },
  225. { title: '产品编码', dataIndex: 'productCode', width: 200, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  226. { title: '调拨数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  227. { title: '单位', dataIndex: 'productUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  228. { title: '成本价', dataIndex: 'cost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  229. { title: '售价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  230. { title: '总成本价', dataIndex: 'totalCost', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  231. { title: '毛利', dataIndex: 'grossProfit', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  232. { title: '仓库', dataIndex: 'warehouseName', width: 200, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  233. { title: '仓位', dataIndex: 'warehouseLocationName', width: 200, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  234. { title: '操作员', dataIndex: 'creatorName', width: 150, align: 'center', sorter: true, customRender: function (text) { return text || '--' }, ellipsis: true },
  235. { title: '调拨类型', dataIndex: 'allocateTypeName', width: 140, align: 'center', customRender: function (text) { return text || '--' } }
  236. ],
  237. // 加载数据方法 必须为 Promise 对象
  238. loadData: parameter => {
  239. this.disabled = true
  240. const params = Object.assign(parameter, this.queryParam)
  241. delete params.time
  242. this.spinning = true
  243. if (params.beginDate) {
  244. return allocateReportDetailList(params).then(res => {
  245. // 总计
  246. this.getCount(params)
  247. const data = res.data
  248. const no = (data.pageNo - 1) * data.pageSize
  249. for (var i = 0; i < data.list.length; i++) {
  250. data.list[i].no = no + i + 1
  251. }
  252. this.disabled = false
  253. this.spinning = false
  254. return data
  255. })
  256. } else {
  257. const _this = this
  258. return new Promise(function (resolve, reject) {
  259. const data = {
  260. pageNo: 1,
  261. pageSize: 10,
  262. list: [],
  263. count: 0
  264. }
  265. _this.disabled = false
  266. _this.spinning = false
  267. _this.$message.info('请选择调拨开单日期')
  268. resolve(data)
  269. })
  270. }
  271. },
  272. allocateTypeList: [], // 调拨类型
  273. productBrandList: [], // 品牌下拉数据
  274. productTypeList: [], // 分类下拉数据
  275. operatorList: [], // 操作员下拉数据
  276. addrProvinceList: [], // 省下拉
  277. totalData: null // 合计
  278. }
  279. },
  280. methods: {
  281. // 盘点库存日期
  282. handleStock () {
  283. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  284. },
  285. // 创建时间 change
  286. dateChange (date) {
  287. this.queryParam.time = date
  288. this.queryParam.beginDate = date[0] || ''
  289. this.queryParam.endDate = date[1] || ''
  290. },
  291. // 合计
  292. getCount (params) {
  293. allocateReportDetailCount(params).then(res => {
  294. if (res.status == 200) {
  295. this.totalData = res.data
  296. } else {
  297. this.totalData = null
  298. }
  299. })
  300. },
  301. // 查询
  302. handleSearch () {
  303. const _this = this
  304. this.$refs.ruleForm.validate(valid => {
  305. if (valid) {
  306. _this.$refs.table.refresh(true)
  307. } else {
  308. console.log('error submit!!')
  309. return false
  310. }
  311. })
  312. },
  313. // 重置
  314. resetSearchForm () {
  315. this.queryParam.time = [
  316. getDate.getCurrMonthDays().starttime,
  317. getDate.getCurrMonthDays().endtime
  318. ]
  319. this.$refs.rangeDate.resetDate(this.queryParam.time)
  320. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  321. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  322. this.queryParam.productName = ''
  323. this.queryParam.productBrandTypeSn = undefined
  324. this.queryParam.productBrandSn = undefined
  325. this.queryParam.productCode = ''
  326. this.queryParam.allocateTypeSn = undefined
  327. this.queryParam.creatorId = undefined
  328. this.queryParam.allocateNo = ''
  329. this.queryParam.productTypeSn1 = ''
  330. this.queryParam.productTypeSn2 = ''
  331. this.queryParam.productTypeSn3 = ''
  332. this.queryParam.dealerName = ''
  333. this.queryParam.dealerLevel = undefined
  334. this.queryParam.subareaSn = undefined
  335. this.queryParam.dealerProvinceSn = undefined
  336. this.productType = []
  337. this.$refs.ruleForm.resetFields()
  338. this.totalData = null
  339. this.$refs.table.clearTable()
  340. },
  341. // 导出
  342. handleExport () {
  343. const _this = this
  344. const params = this.queryParam
  345. this.exportLoading = true
  346. _this.spinning = true
  347. allocateReportDetailExport(params).then(res => {
  348. this.exportLoading = false
  349. _this.spinning = false
  350. if (res.type == 'application/json') {
  351. var reader = new FileReader()
  352. reader.addEventListener('loadend', function () {
  353. const obj = JSON.parse(reader.result)
  354. _this.$notification.error({
  355. message: '提示',
  356. description: obj.message
  357. })
  358. })
  359. reader.readAsText(res)
  360. } else {
  361. this.download(res)
  362. }
  363. })
  364. },
  365. download (data) {
  366. if (!data) { return }
  367. const url = window.URL.createObjectURL(new Blob([data]))
  368. const link = document.createElement('a')
  369. link.style.display = 'none'
  370. link.href = url
  371. const a = moment().format('YYYYMMDDHHmmss')
  372. const fname = '调拨明细报表' + a
  373. link.setAttribute('download', fname + '.xlsx')
  374. document.body.appendChild(link)
  375. link.click()
  376. },
  377. filterOption (input, option) {
  378. return (
  379. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  380. )
  381. },
  382. // 产品分类 change
  383. changeProductType (val, opt) {
  384. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  385. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  386. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  387. },
  388. // 产品品牌 列表
  389. getProductBrand () {
  390. productBrandQuery({}).then(res => {
  391. if (res.status == 200) {
  392. this.productBrandList = res.data
  393. } else {
  394. this.productBrandList = []
  395. }
  396. })
  397. },
  398. // 产品分类 列表
  399. getProductType () {
  400. productTypeQuery({}).then(res => {
  401. if (res.status == 200) {
  402. this.productTypeList = res.data
  403. } else {
  404. this.productTypeList = []
  405. }
  406. })
  407. },
  408. // 调拨类型
  409. getAllocateTypeAllList () {
  410. allocateTypeAllList().then(res => {
  411. if (res.status == 200) {
  412. this.allocateTypeList = res.data
  413. } else {
  414. this.allocateTypeList = []
  415. }
  416. })
  417. },
  418. // 操作员
  419. getUserList () {
  420. userQueryList({}).then(res => {
  421. if (res.status == 200) {
  422. this.operatorList = res.data
  423. } else {
  424. this.operatorList = []
  425. }
  426. })
  427. },
  428. // 省/市/区
  429. getArea (leve, sn) {
  430. let params
  431. if (leve == 'province') {
  432. params = { type: '2' }
  433. } else {
  434. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  435. }
  436. getArea(params).then(res => {
  437. if (res.status == 200) {
  438. if (leve == 'province') {
  439. this.addrProvinceList = res.data || []
  440. } else if (leve == 'city') {
  441. this.addrCityList = res.data || []
  442. } else if (leve == 'district') {
  443. this.addrDistrictList = res.data || []
  444. }
  445. } else {
  446. if (leve == 'province') {
  447. this.addrProvinceList = []
  448. } else if (leve == 'city') {
  449. this.addrCityList = []
  450. } else if (leve == 'district') {
  451. this.addrDistrictList = []
  452. }
  453. }
  454. })
  455. }
  456. },
  457. beforeRouteEnter (to, from, next) {
  458. next(vm => {
  459. vm.getProductBrand()
  460. vm.getProductType()
  461. vm.getAllocateTypeAllList()
  462. vm.getUserList()
  463. vm.getArea('province')
  464. })
  465. }
  466. }
  467. </script>