list.vue 21 KB

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