list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <a-card size="small" :bordered="false" class="hPriceDifferenceDetailList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="hPriceDifferenceDetailList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. @keyup.enter.native="handleSearch">
  14. <a-row :gutter="15">
  15. <a-col :md="6" :sm="24">
  16. <a-form-model-item label="日期" prop="time">
  17. <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
  18. </a-form-model-item>
  19. </a-col>
  20. <a-col :md="5" :sm="24">
  21. <a-form-model-item label="单号">
  22. <a-input id="hPriceDifferenceDetailList-bizNo" v-model.trim="queryParam.bizNo" allowClear placeholder="请输入单号"/>
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-model-item label="客户名称">
  27. <custList id="hPriceDifferenceDetailList-custList" ref="custList" @change="custChange"></custList>
  28. </a-form-model-item>
  29. </a-col>
  30. <template v-if="advanced">
  31. <a-col :md="7" :sm="24">
  32. <a-form-model-item label="客户级别">
  33. <v-select
  34. v-model="queryParam.dealer.dealerLevel"
  35. ref="dealerLevel"
  36. id="hPriceDifferenceDetailList-dealerLevel"
  37. code="DEALER_LEVEL"
  38. placeholder="请选择客户级别"
  39. allowClear></v-select>
  40. </a-form-model-item>
  41. </a-col>
  42. <a-col :md="6" :sm="24">
  43. <a-form-model-item label="品牌分类">
  44. <v-select code="BRAND_TYPE" id="hPriceDifferenceDetailList-brandType" v-model="queryParam.product.brandType" allowClear placeholder="请选择品牌分类"></v-select>
  45. </a-form-model-item>
  46. </a-col>
  47. <a-col :md="6" :sm="24">
  48. <a-form-model-item label="产品品牌">
  49. <ProductBrand id="hPriceDifferenceDetailList-productBrandSn" v-model="queryParam.product.productBrandSn"></ProductBrand>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col :md="6" :sm="24">
  53. <a-form-model-item label="产品分类">
  54. <ProductType id="hPriceDifferenceDetailList-productType" v-model="productType" @change="changeProductType"></ProductType>
  55. </a-form-model-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-model-item label="所在区域">
  59. <subarea id="hPriceDifferenceDetailList-subareaSn" v-model="queryParam.dealer.subareaSn"></subarea>
  60. </a-form-model-item>
  61. </a-col>
  62. <a-col :md="6" :sm="24">
  63. <a-form-model-item label="省级区域">
  64. <a-select id="hPriceDifferenceDetailList-provinceSn" allowClear v-model="queryParam.dealer.provinceSn" placeholder="请选择省">
  65. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  66. </a-select>
  67. </a-form-model-item>
  68. </a-col>
  69. <a-col :md="6" :sm="24">
  70. <a-form-model-item label="类型" prop="bizType">
  71. <a-select id="hPriceDifferenceDetailList-bizType" allowClear v-model="queryParam.bizType" placeholder="请选择类型">
  72. <a-select-option v-for="item in bizTypeList" :value="item.value" :key="item.value">{{ item.name }}</a-select-option>
  73. </a-select>
  74. </a-form-model-item>
  75. </a-col>
  76. </template>
  77. <a-col :md="7" :sm="24" style="margin-bottom: 10px;">
  78. <a-button
  79. type="primary"
  80. class="button-info"
  81. size="small"
  82. @click="handleStock"
  83. id="hPriceDifferenceDetailList-stockDate">盘点区间日期</a-button>
  84. <a-button style="margin-left: 5px" type="primary" @click="handleSearch" :disabled="disabled" id="hPriceDifferenceDetailList-refresh">查询</a-button>
  85. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="hPriceDifferenceDetailList-reset">重置</a-button>
  86. <a @click="advanced=!advanced" style="margin-left: 5px">
  87. {{ advanced ? '收起' : '展开' }}
  88. <a-icon :type="advanced ? 'up' : 'down'"/>
  89. </a>
  90. </a-col>
  91. </a-row>
  92. </a-form-model>
  93. </div>
  94. <!-- 列表 -->
  95. <s-table
  96. class="sTable"
  97. ref="table"
  98. size="small"
  99. :rowKey="(record) => record.id"
  100. :columns="columns"
  101. :data="loadData"
  102. :defaultLoadData="false"
  103. :scroll="{ x: 1850 }"
  104. bordered>
  105. <template slot="footer">
  106. <a-row :gutter="15">
  107. <a-col :md="6" :sm="24" v-if="$hasPermissions('B_isShowPrice')">分公司金额:{{ (totalData && (totalData.wholesalePrice1 || totalData.wholesalePrice1==0)) ? totalData.wholesalePrice1 : '--' }}</a-col>
  108. <a-col :md="6" :sm="24" v-if="$hasPermissions('B_isShowPrice')">加盟商金额:{{ (totalData && (totalData.wholesalePrice2 || totalData.wholesalePrice2==0)) ? totalData.wholesalePrice2 : '--' }}</a-col>
  109. <a-col :md="6" :sm="24" v-if="$hasPermissions('B_isShowPrice')">特约加盟店金额:{{ (totalData && (totalData.wholesalePrice3 || totalData.wholesalePrice3==0)) ? totalData.wholesalePrice3 : '--' }}</a-col>
  110. <a-col :md="6" :sm="24" v-if="$hasPermissions('B_isShowPrice')">直接差价金额:{{ (totalData && (totalData.directRebateAmount || totalData.directRebateAmount==0)) ? totalData.directRebateAmount : '--' }}</a-col>
  111. <a-col :md="6" :sm="24" v-if="$hasPermissions('B_isShowPrice')">间接差价金额:{{ (totalData && (totalData.indirectRebateAmount || totalData.indirectRebateAmount==0)) ? totalData.indirectRebateAmount : '--' }}</a-col>
  112. </a-row>
  113. </template>
  114. </s-table>
  115. </a-spin>
  116. </a-card>
  117. </template>
  118. <script>
  119. import getDate from '@/libs/getDate.js'
  120. import { STable, VSelect } from '@/components'
  121. import rangeDate from '@/views/common/rangeDate.vue'
  122. import custList from '@/views/common/custList.vue'
  123. import subarea from '@/views/common/subarea.js'
  124. import { getArea } from '@/api/data'
  125. import ProductBrand from '@/views/common/productBrand.js'
  126. import ProductType from '@/views/common/productType.js'
  127. import { headRebateDetailReportList, headRebateDetailReportCount } from '@/api/reportData'
  128. export default {
  129. components: { STable, VSelect, custList, subarea, rangeDate, ProductBrand, ProductType },
  130. data () {
  131. return {
  132. spinning: false,
  133. advanced: false, // 高级搜索 展开/关闭
  134. queryParam: { // 查询条件
  135. time: [
  136. getDate.getCurrMonthDays().starttime,
  137. getDate.getCurrMonthDays().endtime
  138. ],
  139. beginDate: getDate.getCurrMonthDays().starttime,
  140. endDate: getDate.getCurrMonthDays().endtime,
  141. bizNo: '',
  142. dealer: {
  143. dealerSn: undefined,
  144. dealerLevel: undefined,
  145. subareaSn: undefined, // 区域
  146. provinceSn: undefined
  147. },
  148. product: {
  149. brandType: undefined,
  150. productBrandSn: undefined, // 产品品牌
  151. productTypeSn1: '', // 产品一级分类
  152. productTypeSn2: '', // 产品二级分类
  153. productTypeSn3: '' // 产品三级分类
  154. },
  155. bizType: undefined
  156. },
  157. rules: {
  158. 'time': [{ required: true, message: '请选择日期', trigger: 'change' }]
  159. },
  160. disabled: false, // 查询、重置按钮是否可操作
  161. addrProvinceList: [], // 省下拉
  162. // 加载数据方法 必须为 Promise 对象
  163. loadData: parameter => {
  164. this.disabled = true
  165. const params = Object.assign(parameter, this.queryParam)
  166. if (!params.dealer.dealerSn && !params.dealer.dealerLevel && !params.dealer.subareaSn && !params.dealer.provinceSn) {
  167. delete params.dealer
  168. }
  169. delete params.time
  170. this.spinning = true
  171. return headRebateDetailReportList(params).then(res => {
  172. // 总计
  173. this.getCount(params)
  174. const data = res.data
  175. const no = (data.pageNo - 1) * data.pageSize
  176. for (var i = 0; i < data.list.length; i++) {
  177. data.list[i].no = no + i + 1
  178. if (data.list[i].bizType) {
  179. data.list[i].bizTypeValue = data.list[i].bizType == 'SALES' ? '采购差价' : data.list[i].bizType == 'SALES_RETURN' ? '退货差价' : ''
  180. }
  181. }
  182. this.disabled = false
  183. this.spinning = false
  184. return data
  185. })
  186. },
  187. productType: [],
  188. bizTypeList: [
  189. { value: 'SALES', name: '采购差价' },
  190. { value: 'SALES_RETURN', name: '退货差价' }
  191. ],
  192. totalData: null
  193. }
  194. },
  195. computed: {
  196. columns () {
  197. const arr = [
  198. { title: '区域', dataIndex: 'dealer.subareaNameSet', width: 120, align: 'center', customRender: function (text) { return (text && text.length > 0) ? text.join('/') : '--' } },
  199. { title: '订单号', dataIndex: 'bizNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  200. { title: '日期', dataIndex: 'bizCreateDate', width: 90, align: 'center', customRender: function (text) { return text || '--' } },
  201. { title: '省份', dataIndex: 'dealer.provinceName', width: 90, align: 'center', customRender: function (text) { return text || '--' } },
  202. { title: '直接绑定客户名称', dataIndex: 'directDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  203. { title: '间接绑定客户名称', dataIndex: 'indirectDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  204. { title: '客户名称', dataIndex: 'dealer.dealerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  205. { title: '客户级别', dataIndex: 'dealer.dealerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  206. { title: '品牌', dataIndex: 'productBrandName', width: 130, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  207. { title: '二级分类', dataIndex: 'productTypeName2', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  208. { title: '数量', dataIndex: 'qty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  209. // { title: '分公司金额', dataIndex: 'wholesalePrice1', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  210. // { title: '加盟商金额', dataIndex: 'wholesalePrice2', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  211. // { title: '特约加盟店金额', dataIndex: 'wholesalePrice3', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  212. // { title: '直接差价', dataIndex: 'directRebateAmount', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  213. // { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  214. { title: '类型', dataIndex: 'bizTypeValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
  215. ]
  216. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  217. arr.splice(11, 0, { title: '分公司金额', dataIndex: 'wholesalePrice1', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  218. arr.splice(12, 0, { title: '加盟商金额', dataIndex: 'wholesalePrice2', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  219. arr.splice(13, 0, { title: '特约加盟店金额', dataIndex: 'wholesalePrice3', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  220. arr.splice(14, 0, { title: '直接差价', dataIndex: 'directRebateAmount', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  221. arr.splice(15, 0, { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  222. }
  223. return arr
  224. }
  225. },
  226. methods: {
  227. // 盘点库存日期
  228. handleStock () {
  229. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  230. },
  231. // 创建时间 change
  232. dateChange (date) {
  233. if (date[0] && date[1]) {
  234. this.queryParam.time = date
  235. } else {
  236. this.queryParam.time = []
  237. }
  238. this.queryParam.beginDate = date[0] || ''
  239. this.queryParam.endDate = date[1] || ''
  240. },
  241. // 合计
  242. getCount (params) {
  243. headRebateDetailReportCount(params).then(res => {
  244. if (res.status == 200) {
  245. this.totalData = res.data
  246. } else {
  247. this.totalData = null
  248. }
  249. })
  250. },
  251. // 查询
  252. handleSearch () {
  253. const _this = this
  254. this.$refs.ruleForm.validate(valid => {
  255. if (valid) {
  256. _this.$refs.table.refresh(true)
  257. } else {
  258. console.log('error submit!!')
  259. return false
  260. }
  261. })
  262. },
  263. custChange (val) {
  264. this.queryParam.dealer.dealerSn = val.key
  265. },
  266. // 产品分类 change
  267. changeProductType (val, opt) {
  268. this.queryParam.product.productTypeSn1 = val[0] ? val[0] : ''
  269. this.queryParam.product.productTypeSn2 = val[1] ? val[1] : ''
  270. this.queryParam.product.productTypeSn3 = val[2] ? val[2] : ''
  271. },
  272. // 省/市/区
  273. getArea (leve, sn) {
  274. let params
  275. if (leve == 'province') {
  276. params = { type: '2' }
  277. } else {
  278. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  279. }
  280. getArea(params).then(res => {
  281. if (res.status == 200) {
  282. if (leve == 'province') {
  283. this.addrProvinceList = res.data || []
  284. } else if (leve == 'city') {
  285. this.addrCityList = res.data || []
  286. } else if (leve == 'district') {
  287. this.addrDistrictList = res.data || []
  288. }
  289. } else {
  290. if (leve == 'province') {
  291. this.addrProvinceList = []
  292. } else if (leve == 'city') {
  293. this.addrCityList = []
  294. } else if (leve == 'district') {
  295. this.addrDistrictList = []
  296. }
  297. }
  298. })
  299. },
  300. // 重置
  301. resetSearchForm () {
  302. this.queryParam.time = [
  303. getDate.getCurrMonthDays().starttime,
  304. getDate.getCurrMonthDays().endtime
  305. ]
  306. this.$refs.rangeDate.resetDate(this.queryParam.time)
  307. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  308. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  309. this.queryParam.bizNo = ''
  310. this.queryParam.dealer.dealerSn = undefined
  311. this.queryParam.dealer.dealerLevel = undefined
  312. this.queryParam.dealer.subareaSn = undefined
  313. this.queryParam.dealer.provinceSn = undefined
  314. this.queryParam.product.brandType = ''
  315. this.queryParam.product.productBrandSn = ''
  316. this.queryParam.product.productTypeSn1 = ''
  317. this.queryParam.product.productTypeSn2 = ''
  318. this.queryParam.product.productTypeSn3 = ''
  319. this.queryParam.bizType = undefined
  320. this.productType = []
  321. this.totalData = null
  322. this.$refs.custList.resetForm()
  323. this.$refs.ruleForm.resetFields()
  324. this.$refs.table.clearTable()
  325. },
  326. pageInit () {
  327. this.getArea('province')
  328. }
  329. },
  330. mounted () {
  331. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  332. this.pageInit()
  333. this.resetSearchForm()
  334. }
  335. },
  336. activated () {
  337. // 如果是新页签打开,则重置当前页面
  338. if (this.$store.state.app.isNewTab) {
  339. this.pageInit()
  340. this.resetSearchForm()
  341. }
  342. },
  343. beforeRouteEnter (to, from, next) {
  344. next(vm => {})
  345. }
  346. }
  347. </script>