list.vue 21 KB

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