list.vue 21 KB

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