list.vue 21 KB

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