list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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="7" :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-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-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="7" :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 @click="advanced=!advanced" style="margin-left: 8px">
  119. {{ advanced ? '收起' : '展开' }}
  120. <a-icon :type="advanced ? 'up' : 'down'"/>
  121. </a>
  122. </a-col>
  123. </a-row>
  124. </a-form-model>
  125. </div>
  126. <!-- 列表 -->
  127. <s-table
  128. class="sTable"
  129. ref="table"
  130. size="small"
  131. :rowKey="(record) => record.id"
  132. :columns="columns"
  133. :data="loadData"
  134. :defaultLoadData="false"
  135. :scroll="{ x: 3430 }"
  136. bordered>
  137. <template slot="footer" slot-scope="currentPageData">
  138. <a-row :gutter="15">
  139. <a-col :md="4" :sm="24">
  140. 总数量:{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}
  141. </a-col>
  142. <a-col :md="4" :sm="24">
  143. 总成本价:{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? totalData.totalCost : '--' }}
  144. </a-col>
  145. <a-col :md="4" :sm="24">
  146. 总毛利:{{ (totalData && (totalData.totalGrossProfit || totalData.totalGrossProfit==0)) ? totalData.totalGrossProfit : '--' }}
  147. </a-col>
  148. <a-col :md="4" :sm="24">
  149. 总售价:{{ (totalData && (totalData.totalPrice || totalData.totalPrice==0)) ? totalData.totalPrice : '--' }}
  150. </a-col>
  151. </a-row>
  152. </template>
  153. </s-table>
  154. </a-spin>
  155. </a-card>
  156. </template>
  157. <script>
  158. import { STable, VSelect } from '@/components'
  159. import rangeDate from '@/views/common/rangeDate.vue'
  160. import subarea from '@/views/common/subarea.js'
  161. import { productBrandQuery } from '@/api/productBrand'
  162. import { productTypeQuery } from '@/api/productType'
  163. import { getArea } from '@/api/data'
  164. import { allocateTypeAllList } from '@/api/allocateType'
  165. import { userQueryList } from '@/api/power-user'
  166. import { allocateReportDetailList, allocateReportDetailCount } from '@/api/allocateReport'
  167. export default {
  168. components: { STable, VSelect, rangeDate, subarea },
  169. data () {
  170. return {
  171. spinning: false,
  172. advanced: false, // 高级搜索 展开/关闭
  173. tableHeight: 0,
  174. queryParam: { // 查询条件
  175. time: [],
  176. beginDate: '',
  177. endDate: '',
  178. productName: '',
  179. productBrandTypeSn: undefined,
  180. productBrandSn: undefined, // 产品品牌
  181. productCode: '',
  182. allocateTypeSn: undefined, // 调拨类型
  183. creatorId: undefined,
  184. allocateNo: '',
  185. productTypeSn1: '', // 产品一级分类
  186. productTypeSn2: '', // 产品二级分类
  187. productTypeSn3: '', // 产品三级分类
  188. dealerName: '',
  189. dealerLevel: undefined,
  190. subareaSn: undefined,
  191. dealerProvinceSn: undefined
  192. },
  193. productType: [],
  194. labelCol: { span: 8 },
  195. wrapperCol: { span: 16 },
  196. rules: {
  197. 'time': [{ required: true, message: '请选择调拨开单日期', trigger: 'change' }]
  198. },
  199. disabled: false, // 查询、重置按钮是否可操作
  200. columns: [
  201. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  202. { title: '区域', dataIndex: 'subareaNames', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  203. { title: '调拨单号', dataIndex: 'allocateNo', width: 220, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  204. { title: '调拨开单日期', dataIndex: 'allocateDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  205. { title: '省份', dataIndex: 'dealerProvinceName', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  206. { title: '客户名称', dataIndex: 'targetName', align: 'center', sorter: true, customRender: function (text) { return text || '--' }, ellipsis: true },
  207. { title: '客户级别', dataIndex: 'dealerLevelDictValue', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  208. { title: '品牌', dataIndex: 'productBrandName', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  209. { title: '二级分类', dataIndex: 'productTypeName2', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  210. { title: '产品名称', dataIndex: 'productName', align: 'center', sorter: true, customRender: function (text) { return text || '--' }, ellipsis: true },
  211. { title: '产品编码', dataIndex: 'productCode', width: 200, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  212. { title: '调拨数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  213. { title: '单位', dataIndex: 'productUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  214. { title: '成本价', dataIndex: 'cost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  215. { title: '售价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  216. { title: '总成本价', dataIndex: 'totalCost', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  217. { title: '毛利', dataIndex: 'grossProfit', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  218. { title: '仓库', dataIndex: 'warehouseName', width: 200, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  219. { title: '仓位', dataIndex: 'warehouseLocationName', width: 200, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  220. { title: '操作员', dataIndex: 'creatorName', width: 150, align: 'center', sorter: true, customRender: function (text) { return text || '--' }, ellipsis: true },
  221. { title: '调拨类型', dataIndex: 'allocateTypeName', width: 140, align: 'center', customRender: function (text) { return text || '--' } }
  222. ],
  223. // 加载数据方法 必须为 Promise 对象
  224. loadData: parameter => {
  225. this.disabled = true
  226. const params = Object.assign(parameter, this.queryParam)
  227. delete params.time
  228. this.spinning = true
  229. if (params.beginDate) {
  230. return allocateReportDetailList(params).then(res => {
  231. // 总计
  232. this.getCount(params)
  233. const data = res.data
  234. const no = (data.pageNo - 1) * data.pageSize
  235. for (var i = 0; i < data.list.length; i++) {
  236. data.list[i].no = no + i + 1
  237. }
  238. this.disabled = false
  239. this.spinning = false
  240. return data
  241. })
  242. } else {
  243. const _this = this
  244. return new Promise(function (resolve, reject) {
  245. const data = {
  246. pageNo: 1,
  247. pageSize: 10,
  248. list: [],
  249. count: 0
  250. }
  251. _this.disabled = false
  252. _this.spinning = false
  253. _this.$message.info('请选择调拨开单日期')
  254. resolve(data)
  255. })
  256. }
  257. },
  258. allocateTypeList: [], // 调拨类型
  259. productBrandList: [], // 品牌下拉数据
  260. productTypeList: [], // 分类下拉数据
  261. operatorList: [], // 操作员下拉数据
  262. addrProvinceList: [], // 省下拉
  263. totalData: null // 合计
  264. }
  265. },
  266. methods: {
  267. // 盘点库存日期
  268. handleStock () {
  269. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  270. },
  271. // 创建时间 change
  272. dateChange (date) {
  273. if (date.length) {
  274. if (date[0] == '' && date[1] == '') {
  275. this.resetSearchForm()
  276. } else {
  277. this.queryParam.time = date
  278. }
  279. }
  280. this.queryParam.beginDate = date[0]
  281. this.queryParam.endDate = date[1]
  282. },
  283. // 合计
  284. getCount (params) {
  285. allocateReportDetailCount(params).then(res => {
  286. if (res.status == 200) {
  287. this.totalData = res.data
  288. } else {
  289. this.totalData = null
  290. }
  291. })
  292. },
  293. // 查询
  294. handleSearch () {
  295. const _this = this
  296. this.$refs.ruleForm.validate(valid => {
  297. if (valid) {
  298. _this.$refs.table.refresh(true)
  299. } else {
  300. console.log('error submit!!')
  301. return false
  302. }
  303. })
  304. },
  305. // 重置
  306. resetSearchForm () {
  307. this.$refs.rangeDate.resetDate()
  308. this.queryParam.time = []
  309. this.queryParam.beginDate = ''
  310. this.queryParam.endDate = ''
  311. this.queryParam.productName = ''
  312. this.queryParam.productBrandTypeSn = undefined
  313. this.queryParam.productBrandSn = undefined
  314. this.queryParam.productCode = ''
  315. this.queryParam.allocateTypeSn = undefined
  316. this.queryParam.creatorId = undefined
  317. this.queryParam.allocateNo = ''
  318. this.queryParam.productTypeSn1 = ''
  319. this.queryParam.productTypeSn2 = ''
  320. this.queryParam.productTypeSn3 = ''
  321. this.queryParam.dealerName = ''
  322. this.queryParam.dealerLevel = undefined
  323. this.queryParam.subareaSn = undefined
  324. this.queryParam.dealerProvinceSn = undefined
  325. this.productType = []
  326. this.$refs.ruleForm.resetFields()
  327. this.totalData = null
  328. this.$refs.table.clearTable()
  329. },
  330. filterOption (input, option) {
  331. return (
  332. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  333. )
  334. },
  335. // 产品分类 change
  336. changeProductType (val, opt) {
  337. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  338. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  339. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  340. },
  341. // 产品品牌 列表
  342. getProductBrand () {
  343. productBrandQuery({}).then(res => {
  344. if (res.status == 200) {
  345. this.productBrandList = res.data
  346. } else {
  347. this.productBrandList = []
  348. }
  349. })
  350. },
  351. // 产品分类 列表
  352. getProductType () {
  353. productTypeQuery({}).then(res => {
  354. if (res.status == 200) {
  355. this.productTypeList = res.data
  356. } else {
  357. this.productTypeList = []
  358. }
  359. })
  360. },
  361. // 调拨类型
  362. getAllocateTypeAllList () {
  363. allocateTypeAllList().then(res => {
  364. if (res.status == 200) {
  365. this.allocateTypeList = res.data
  366. } else {
  367. this.allocateTypeList = []
  368. }
  369. })
  370. },
  371. // 操作员
  372. getUserList () {
  373. userQueryList({}).then(res => {
  374. if (res.status == 200) {
  375. this.operatorList = res.data
  376. } else {
  377. this.operatorList = []
  378. }
  379. })
  380. },
  381. // 省/市/区
  382. getArea (leve, sn) {
  383. let params
  384. if (leve == 'province') {
  385. params = { type: '2' }
  386. } else {
  387. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  388. }
  389. getArea(params).then(res => {
  390. if (res.status == 200) {
  391. if (leve == 'province') {
  392. this.addrProvinceList = res.data || []
  393. } else if (leve == 'city') {
  394. this.addrCityList = res.data || []
  395. } else if (leve == 'district') {
  396. this.addrDistrictList = res.data || []
  397. }
  398. } else {
  399. if (leve == 'province') {
  400. this.addrProvinceList = []
  401. } else if (leve == 'city') {
  402. this.addrCityList = []
  403. } else if (leve == 'district') {
  404. this.addrDistrictList = []
  405. }
  406. }
  407. })
  408. }
  409. },
  410. beforeRouteEnter (to, from, next) {
  411. next(vm => {
  412. vm.getProductBrand()
  413. vm.getProductType()
  414. vm.getAllocateTypeAllList()
  415. vm.getUserList()
  416. vm.getArea('province')
  417. })
  418. }
  419. }
  420. </script>