list.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. subareaSn: undefined,
  187. subareaAreaSn: undefined, // 分区
  188. dealerProvinceSn: undefined
  189. },
  190. productType: [],
  191. labelCol: { span: 8 },
  192. wrapperCol: { span: 16 },
  193. rules: {
  194. 'time': [{ required: true, message: '请选择调拨开单日期', trigger: 'change' }]
  195. },
  196. disabled: false, // 查询、重置按钮是否可操作
  197. // 加载数据方法 必须为 Promise 对象
  198. loadData: parameter => {
  199. this.disabled = true
  200. const params = Object.assign(parameter, this.queryParam)
  201. delete params.time
  202. this.spinning = true
  203. if (params.beginDate) {
  204. return allocateReportDetailList(params).then(res => {
  205. let data
  206. if (res.status == 200) {
  207. data = res.data
  208. // 总计
  209. this.getCount(params)
  210. const no = (data.pageNo - 1) * data.pageSize
  211. for (var i = 0; i < data.list.length; i++) {
  212. data.list[i].no = no + i + 1
  213. }
  214. this.disabled = false
  215. }
  216. this.spinning = false
  217. return data
  218. })
  219. } else {
  220. const _this = this
  221. return new Promise(function (resolve, reject) {
  222. const data = {
  223. pageNo: 1,
  224. pageSize: 10,
  225. list: [],
  226. count: 0
  227. }
  228. _this.disabled = false
  229. _this.spinning = false
  230. _this.$message.info('请选择调拨开单日期')
  231. resolve(data)
  232. })
  233. }
  234. },
  235. allocateTypeList: [], // 调拨类型
  236. operatorList: [], // 操作员下拉数据
  237. totalData: null // 合计
  238. }
  239. },
  240. computed: {
  241. columns () {
  242. const _this = this
  243. const arr = [
  244. { title: '区域', dataIndex: 'subareaArea.subareaName', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  245. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  246. { title: '调拨单号', dataIndex: 'allocateNo', width: 160, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  247. { title: '调拨开单日期', dataIndex: 'allocateDate', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  248. { title: '省份', dataIndex: 'dealerProvinceName', width: 90, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  249. { title: '客户名称', dataIndex: 'targetName', width: 120, align: 'center', sorter: true, customRender: function (text) { return text || '--' }, ellipsis: true },
  250. { title: '客户级别', dataIndex: 'dealerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  251. { title: '品牌', dataIndex: 'productBrandName', width: 130, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  252. { title: '二级分类', dataIndex: 'productTypeName2', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  253. { title: '产品名称', dataIndex: 'productName', align: 'left', sorter: true, customRender: function (text) { return text || '--' }, ellipsis: true },
  254. { title: '产品编码', dataIndex: 'productCode', width: 150, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  255. { title: '调拨数量', dataIndex: 'qty', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  256. { title: '单位', dataIndex: 'productUnit', width: 50, align: 'center', customRender: function (text) { return text || '--' } },
  257. // { title: '成本价', dataIndex: 'cost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  258. // { title: '售价', dataIndex: 'price', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  259. // { title: '总成本价', dataIndex: 'totalCost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  260. // { title: '毛利', dataIndex: 'grossProfit', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  261. ]
  262. if (this.$hasPermissions('M_allocationDetailsList_costPrice')) { // 成本价权限
  263. arr.push({ title: '成本价', dataIndex: 'cost', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  264. }
  265. if (this.$hasPermissions('M_allocationDetailsList_salesPrice')) { // 售价权限
  266. arr.push({ title: '售价', dataIndex: 'price', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  267. }
  268. if (this.$hasPermissions('M_allocationDetailsList_costPrice')) { // 成本价权限
  269. arr.push({ title: '总成本价', dataIndex: 'totalCost', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  270. if (this.$hasPermissions('M_allocationDetailsList_salesPrice')) {
  271. arr.push({ title: '毛利', dataIndex: 'grossProfit', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  272. }
  273. }
  274. arr.concat([
  275. { title: '仓库', dataIndex: 'warehouseName', width: 90, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  276. { title: '仓位', dataIndex: 'warehouseLocationName', width: 90, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  277. { title: '操作员', dataIndex: 'creatorName', width: 100, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  278. { title: '费用类型', dataIndex: 'costTypeName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  279. { title: '调拨类型(一级)', dataIndex: 'allocateSortName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  280. { title: '调拨类型(二级)', dataIndex: 'allocateTypeName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  281. { title: '费用归属品牌', dataIndex: 'costProductBrandName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  282. { title: '费用归属品类(二级)', dataIndex: 'costProductTypeName2', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  283. { title: '费用归属品类(三级)', dataIndex: 'costProductTypeName3', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  284. { title: '费用归属部门', dataIndex: 'departmentName', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
  285. ])
  286. return arr
  287. }
  288. },
  289. methods: {
  290. // 盘点库存日期
  291. handleStock () {
  292. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  293. },
  294. // 创建时间 change
  295. dateChange (date) {
  296. if (date[0] && date[1]) {
  297. this.queryParam.time = date
  298. } else {
  299. this.queryParam.time = []
  300. }
  301. this.queryParam.beginDate = date[0] || ''
  302. this.queryParam.endDate = date[1] || ''
  303. },
  304. changeAllocatype (val, opts) {
  305. this.allocateTypeVal = val || []
  306. this.queryParam.costTypeSn = val && val[0] ? val[0] : ''
  307. this.queryParam.allocateSortSn = val && val[1] ? val[1] : ''
  308. this.queryParam.allocateTypeSn = val && val[2] ? val[2] : ''
  309. },
  310. // 合计
  311. getCount (params) {
  312. allocateReportDetailCount(params).then(res => {
  313. if (res.status == 200) {
  314. this.totalData = res.data
  315. } else {
  316. this.totalData = null
  317. }
  318. })
  319. },
  320. // 查询
  321. handleSearch () {
  322. const _this = this
  323. this.$refs.ruleForm.validate(valid => {
  324. if (valid) {
  325. _this.$refs.table.refresh(true)
  326. } else {
  327. _this.$message.error("请选择调拨开单日期")
  328. return false
  329. }
  330. })
  331. },
  332. subareaChange(val){
  333. this.queryParam.subareaSn = val[0] ? val[0] : undefined
  334. this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
  335. },
  336. // 重置
  337. resetSearchForm () {
  338. this.queryParam.time = [
  339. getDate.getCurrMonthDays().starttime,
  340. getDate.getCurrMonthDays().endtime
  341. ]
  342. this.$refs.rangeDate.resetDate(this.queryParam.time)
  343. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  344. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  345. this.queryParam.productName = ''
  346. this.queryParam.productBrandTypeSn = undefined
  347. this.queryParam.productBrandSn = undefined
  348. this.queryParam.productCode = ''
  349. this.queryParam.costTypeSn = undefined
  350. this.queryParam.allocateSortSn = undefined
  351. this.queryParam.allocateTypeSn = undefined
  352. this.queryParam.creatorId = undefined
  353. this.queryParam.allocateNo = ''
  354. this.queryParam.productTypeSn1 = ''
  355. this.queryParam.productTypeSn2 = ''
  356. this.queryParam.productTypeSn3 = ''
  357. this.queryParam.dealerName = ''
  358. this.queryParam.dealerLevel = undefined
  359. this.queryParam.subareaSn = undefined
  360. this.queryParam.subareaAreaSn = undefined
  361. this.queryParam.dealerProvinceSn = undefined
  362. this.productType = []
  363. this.allocateTypeVal = []
  364. if(this.advanced){
  365. this.$refs.subarea.clearData()
  366. }
  367. this.$refs.ruleForm.resetFields()
  368. this.totalData = null
  369. this.$refs.table.clearTable()
  370. },
  371. // 导出
  372. handleExport () {
  373. const _this = this
  374. this.$refs.ruleForm.validate(valid => {
  375. if (valid) {
  376. const params = _this.queryParam
  377. _this.$store.state.app.curActionPermission = 'B_allocationDetails_Export'
  378. _this.showExport = true
  379. _this.exportLoading = true
  380. _this.spinning = true
  381. hdExportExcel(allocateReportDetailExport, params, '调拨明细报表', function () {
  382. _this.exportLoading = false
  383. _this.spinning = false
  384. _this.$store.state.app.curActionPermission = ''
  385. })
  386. } else {
  387. console.log('error submit!!')
  388. return false
  389. }
  390. })
  391. },
  392. // 产品分类 change
  393. changeProductType (val, opt) {
  394. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  395. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  396. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  397. },
  398. // 调拨类型
  399. getAllocateTypeAllList () {
  400. allocateTypeAllList().then(res => {
  401. if (res.status == 200) {
  402. this.allocateTypeList = res.data
  403. } else {
  404. this.allocateTypeList = []
  405. }
  406. })
  407. },
  408. // 操作员
  409. getUserList () {
  410. userQueryList({}).then(res => {
  411. if (res.status == 200) {
  412. this.operatorList = res.data
  413. } else {
  414. this.operatorList = []
  415. }
  416. })
  417. },
  418. pageInit () {
  419. this.getAllocateTypeAllList()
  420. this.getUserList()
  421. this.resetSearchForm()
  422. }
  423. },
  424. mounted () {
  425. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  426. this.pageInit()
  427. }
  428. },
  429. activated () {
  430. // 如果是新页签打开,则重置当前页面
  431. if (this.$store.state.app.isNewTab) {
  432. this.pageInit()
  433. }
  434. },
  435. beforeRouteEnter (to, from, next) {
  436. next(vm => {})
  437. }
  438. }
  439. </script>