list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <a-spin :spinning="spinning" tip="Loading...">
  3. <a-alert :show-icon="false" type="error" message="注:连锁销售单报表包含急件销售数量、售价,连锁销售明细报表不包含急件销售数量、成本、售价" banner style="margin-bottom: 10px;" />
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="chainSalesDetailReportList-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="tenantId">
  19. <a-select
  20. placeholder="请选择连锁店"
  21. id="chainSalesDetailReportList-tenantId"
  22. allowClear
  23. v-model="queryParam.tenantId"
  24. :showSearch="true"
  25. option-filter-prop="children"
  26. :filter-option="filterOption">
  27. <a-select-option v-for="item in linkageGroupData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
  28. </a-select>
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :md="6" :sm="24">
  32. <a-form-model-item label="审核时间" prop="time">
  33. <rangeDate ref="rangeDate" @change="dateChange" />
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24">
  37. <a-form-model-item label="客户名称">
  38. <a-input id="chainSalesDetailReportList-salesTargetName" v-model.trim="queryParam.salesTargetName" allowClear placeholder="请输入客户名称"/>
  39. </a-form-model-item>
  40. </a-col>
  41. <template v-if="advanced">
  42. <a-col :md="6" :sm="24">
  43. <a-form-model-item label="客户类型">
  44. <a-select id="chainSalesDetailReportList-customerType" v-model="queryParam.salesTargetType" allowClear placeholder="请选择客户类型">
  45. <a-select-option v-for="item in custTypeList" :value="item.customerTypeSn" :key="item.customerTypeSn">{{ item.name }}</a-select-option>
  46. </a-select>
  47. </a-form-model-item>
  48. </a-col>
  49. <a-col :md="6" :sm="24">
  50. <a-form-model-item label="收款方式">
  51. <v-select
  52. code="SETTLE_STYLE"
  53. id="chainSalesDetailReportList-settleStyleSn"
  54. v-model="queryParam.settleStyleSn"
  55. allowClear
  56. placeholder="请选择收款方式"
  57. ></v-select>
  58. </a-form-model-item>
  59. </a-col>
  60. <a-col :md="6" :sm="24">
  61. <a-form-model-item label="产品品牌">
  62. <ProductBrand id="chainSalesDetailReportList-productBrandSn" placeholder="请选择产品品牌" v-model="queryParam.productEntity.productBrandSn"></ProductBrand>
  63. </a-form-model-item>
  64. </a-col>
  65. <a-col :md="6" :sm="24">
  66. <a-form-model-item label="产品分类">
  67. <ProductType id="chainSalesDetailReportList-productType" placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
  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="chainSalesDetailReportList-code" v-model.trim="queryParam.productEntity.code" allowClear placeholder="请输入产品编码"/>
  73. </a-form-model-item>
  74. </a-col>
  75. <a-col :md="6" :sm="24">
  76. <a-form-model-item label="产品名称">
  77. <a-input id="chainSalesDetailReportList-name" v-model.trim="queryParam.productEntity.name" allowClear placeholder="请输入产品名称"/>
  78. </a-form-model-item>
  79. </a-col>
  80. <a-col :md="6" :sm="24">
  81. <a-form-model-item label="仓库仓位">
  82. <a-cascader
  83. v-model="queryParam.warehouseCascade"
  84. expand-trigger="hover"
  85. :options="warehouseCascadeData"
  86. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  87. id="chainSalesDetailReportList-warehouseCascade"
  88. placeholder="请选择仓库仓位"
  89. @change="warehouseCascadeChange"
  90. allowClear
  91. style="width: 100%;" />
  92. </a-form-model-item>
  93. </a-col>
  94. <a-col :md="6" :sm="24">
  95. <a-form-model-item label="单号">
  96. <a-input id="chainSalesDetailReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入单号"/>
  97. </a-form-model-item>
  98. </a-col>
  99. <a-col :md="6" :sm="24">
  100. <a-form-model-item label="业务员">
  101. <a-input id="chainSalesDetailReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
  102. </a-form-model-item>
  103. </a-col>
  104. <a-col :md="12" :sm="24">
  105. <a-row>
  106. <a-form-model-item label="客户所在区" :labelCol="{span: 4}" :wrapperCol="{ span: 20 }" style="margin-bottom: 0!important;">
  107. <a-col span="7">
  108. <a-form-model-item prop="provinceSn" style="margin: 0;">
  109. <a-select v-model="queryParam.provinceSn" @change="getCityList" placeholder="请选择省" allowClear>
  110. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  111. </a-select>
  112. </a-form-model-item>
  113. </a-col>
  114. <a-col span="7" offset="1">
  115. <a-form-model-item prop="citySn" style="margin: 0;">
  116. <a-select v-model="queryParam.citySn" @change="getAreaList" placeholder="请选择市" allowClear>
  117. <a-select-option v-for="item in addrCityList" :value="item.areaSn" :key="item.areaSn + 'b'">{{ item.name }}</a-select-option>
  118. </a-select>
  119. </a-form-model-item>
  120. </a-col>
  121. <a-col span="7" offset="1">
  122. <a-form-model-item prop="countySn" style="margin: 0;">
  123. <a-select v-model="queryParam.countySn" placeholder="请选择区/县" allowClear>
  124. <a-select-option v-for="item in addrDistrictList" :value="item.areaSn" :key="item.areaSn + 'c'">{{ item.name }}</a-select-option>
  125. </a-select>
  126. </a-form-model-item>
  127. </a-col>
  128. </a-form-model-item>
  129. </a-row>
  130. </a-col>
  131. </template>
  132. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  133. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainSalesDetailReportList-refresh">查询</a-button>
  134. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainSalesDetailReportList-reset">重置</a-button>
  135. <a @click="advanced=!advanced" style="margin-left: 5px">
  136. {{ advanced ? '收起' : '展开' }}
  137. <a-icon :type="advanced ? 'up' : 'down'"/>
  138. </a>
  139. </a-col>
  140. </a-row>
  141. </a-form-model>
  142. </div>
  143. <!-- 合计 -->
  144. <a-alert type="info" style="margin-bottom:10px">
  145. <div class="ftext" slot="message">
  146. 产品总数量:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
  147. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  148. 总成本:<strong>{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? toThousands(totalData.totalCost) : '--' }}</strong>;
  149. </div>
  150. 总售价:<strong>{{ (totalData && (totalData.totalPrice || totalData.totalPrice==0)) ? toThousands(totalData.totalPrice) : '--' }}</strong>;
  151. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  152. 总毛利:<strong>{{ (totalData && (totalData.totalProfit || totalData.totalProfit==0)) ? toThousands(totalData.totalProfit) : '--' }}</strong>。
  153. </div>
  154. </div>
  155. </a-alert>
  156. <!-- 列表 -->
  157. <s-table
  158. class="sTable"
  159. ref="table"
  160. size="small"
  161. :rowKey="(record) => record.id"
  162. :columns="columns"
  163. :data="loadData"
  164. :defaultLoadData="false"
  165. bordered>
  166. </s-table>
  167. </a-spin>
  168. </template>
  169. <script>
  170. import { commonMixin } from '@/utils/mixin'
  171. import { STable, VSelect } from '@/components'
  172. import rangeDate from '@/views/common/rangeDate.vue'
  173. import { getArea } from '@/api/data'
  174. import { custTypeFindAllList } from '@/api/custType'
  175. import ProductType from '../../common/productType.js'
  176. import ProductBrand from '../../common/productBrand.js'
  177. import { warehouseCascadeList } from '@/api/warehouse'
  178. import { reportChainSalesBillDetailList, reportChainSalesBillDetailCount, linkageGroupList } from '@/api/reportData'
  179. export default {
  180. components: { STable, VSelect, rangeDate, ProductType, ProductBrand },
  181. mixins: [commonMixin],
  182. data () {
  183. return {
  184. spinning: false,
  185. labelCol: { span: 8 },
  186. wrapperCol: { span: 16 },
  187. advanced: false, // 高级搜索 展开/关闭
  188. tableHeight: 0,
  189. queryParam: { // 查询条件
  190. tenantId: undefined,
  191. time: [],
  192. beginDate: '',
  193. endDate: '',
  194. salesTargetName: '',
  195. salesTargetType: undefined,
  196. provinceSn: undefined, // 省
  197. citySn: undefined, // 市
  198. countySn: undefined, // 区
  199. settleStyleSn: undefined,
  200. productEntity: {
  201. productBrandSn: undefined, // 产品品牌
  202. productTypeSn1: '', // 产品一级分类
  203. productTypeSn2: '', // 产品二级分类
  204. productTypeSn3: '', // 产品三级分类
  205. code: '', // 产品编码
  206. name: '' // 产品名称
  207. },
  208. warehouseCascade: [],
  209. warehouseSn: undefined,
  210. warehouseLocationSn: undefined,
  211. salesBillNo: '',
  212. salesManName: ''
  213. },
  214. rules: {
  215. 'tenantId': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
  216. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  217. },
  218. disabled: false, // 查询、重置按钮是否可操作
  219. exportLoading: false,
  220. // 加载数据方法 必须为 Promise 对象
  221. loadData: parameter => {
  222. this.disabled = true
  223. const params = Object.assign(parameter, this.queryParam)
  224. this.spinning = true
  225. delete params.time
  226. delete params.warehouseCascade
  227. return reportChainSalesBillDetailList(params).then(res => {
  228. let data
  229. if (res.status == 200) {
  230. data = res.data
  231. // 总计
  232. this.getCount(params)
  233. const no = (data.pageNo - 1) * data.pageSize
  234. for (var i = 0; i < data.list.length; i++) {
  235. data.list[i].no = no + i + 1
  236. }
  237. this.disabled = false
  238. }
  239. this.spinning = false
  240. return data
  241. })
  242. },
  243. totalData: null, // 合计
  244. addrProvinceList: [], // 省下拉
  245. addrCityList: [], // 市下拉
  246. addrDistrictList: [], // 区下拉
  247. linkageGroupData: [],
  248. allocateTypeList: [], // 调拨类型
  249. custTypeList: [], // 客户类型 下拉数据
  250. productBrandList: [], // 品牌下拉数据
  251. productType: [],
  252. productTypeList: [], // 分类下拉数据
  253. warehouseCascadeData: [] // 仓库仓位
  254. }
  255. },
  256. computed: {
  257. columns () {
  258. const _this = this
  259. const arr = [
  260. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  261. { title: '销售单号', dataIndex: 'salesBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  262. { title: '客户名称', dataIndex: 'salesTargetName', width: '13%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  263. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  264. { title: '产品编码', dataIndex: 'productEntity.code', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  265. { title: '产品名称', dataIndex: 'productEntity.name', width: '14%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  266. { title: '单位', dataIndex: 'productEntity.unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  267. { title: '数量', dataIndex: 'productQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  268. // { title: '成本', dataIndex: 'productCost', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  269. { title: '售价', dataIndex: 'productPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  270. // { title: '毛利', dataIndex: 'productProfit', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  271. { title: '审核时间', dataIndex: 'salesAuditDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } }
  272. ]
  273. if (this.$hasPermissions('M_ShowAllCost')) {
  274. arr.splice(8, 0, { title: '成本', dataIndex: 'productCost', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  275. arr.splice(10, 0, { title: '毛利', dataIndex: 'productProfit', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  276. }
  277. return arr
  278. }
  279. },
  280. methods: {
  281. // 合计
  282. getCount (params) {
  283. reportChainSalesBillDetailCount(params).then(res => {
  284. if (res.status == 200) {
  285. this.totalData = res.data
  286. } else {
  287. this.totalData = null
  288. }
  289. })
  290. },
  291. // 创建时间 change
  292. dateChange (date) {
  293. this.queryParam.time = date
  294. this.queryParam.beginDate = date[0] || ''
  295. this.queryParam.endDate = date[1] || ''
  296. },
  297. // 查询
  298. handleSearch () {
  299. this.$refs.ruleForm.validate(valid => {
  300. if (valid) {
  301. this.$refs.table.refresh(true)
  302. } else {
  303. console.log('error submit!!')
  304. return false
  305. }
  306. })
  307. },
  308. // 重置
  309. resetSearchForm () {
  310. this.queryParam.tenantId = undefined
  311. this.$refs.rangeDate.resetDate()
  312. this.queryParam.time = []
  313. this.queryParam.beginDate = ''
  314. this.queryParam.endDate = ''
  315. this.queryParam.salesTargetName = ''
  316. this.queryParam.salesTargetType = undefined
  317. this.queryParam.provinceSn = undefined
  318. this.queryParam.citySn = undefined
  319. this.queryParam.countySn = undefined
  320. this.queryParam.settleStyleSn = undefined
  321. this.queryParam.productEntity.productBrandSn = undefined
  322. this.queryParam.productEntity.productTypeSn1 = ''
  323. this.queryParam.productEntity.productTypeSn2 = ''
  324. this.queryParam.productEntity.productTypeSn3 = ''
  325. this.queryParam.productEntity.code = ''
  326. this.queryParam.productEntity.name = ''
  327. this.queryParam.warehouseSn = undefined
  328. this.queryParam.warehouseLocationSn = undefined
  329. this.queryParam.warehouseCascade = []
  330. this.queryParam.salesBillNo = ''
  331. this.queryParam.salesManName = ''
  332. this.productType = []
  333. this.$refs.ruleForm.resetFields()
  334. this.totalData = null
  335. this.$refs.table.clearTable()
  336. },
  337. filterOption (input, option) {
  338. return (
  339. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  340. )
  341. },
  342. // 获取客户类型列表
  343. getCustTypeList () {
  344. const _this = this
  345. custTypeFindAllList().then(res => {
  346. if (res.status == 200) {
  347. _this.custTypeList = res.data || []
  348. } else {
  349. _this.custTypeList = []
  350. }
  351. })
  352. },
  353. // 产品分类 change
  354. changeProductType (val, opt) {
  355. this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
  356. this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
  357. this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
  358. },
  359. // 连锁店
  360. getLinkageGroup () {
  361. linkageGroupList({}).then(res => {
  362. if (res.status == 200) {
  363. const data = res.data || []
  364. if (data.length > 0) {
  365. this.linkageGroupData = data
  366. } else {
  367. this.linkageGroupData = []
  368. }
  369. } else {
  370. this.linkageGroupData = []
  371. }
  372. })
  373. },
  374. // 仓库仓位 级联 列表
  375. getWarehouseCascade () {
  376. warehouseCascadeList({}).then(res => {
  377. if (res.status == 200) {
  378. res.data.map(item => {
  379. item.sn = item.warehouseSn
  380. if (item.warehouseLocationList) {
  381. item.warehouseLocationList.map(subItem => {
  382. subItem.sn = subItem.warehouseLocationSn
  383. })
  384. }
  385. })
  386. this.warehouseCascadeData = res.data
  387. } else {
  388. this.warehouseCascadeData = []
  389. }
  390. })
  391. },
  392. // 仓库仓位change
  393. warehouseCascadeChange (val) {
  394. if (val && val.length > 0) {
  395. this.queryParam.warehouseSn = val[0] || ''
  396. this.queryParam.warehouseLocationSn = val[1] || ''
  397. } else {
  398. this.queryParam.warehouseSn = ''
  399. this.queryParam.warehouseLocationSn = ''
  400. }
  401. },
  402. // 获取城市列表
  403. getCityList (val) {
  404. this.addrCityList = []
  405. this.addrDistrictList = []
  406. this.queryParam.citySn = undefined
  407. this.queryParam.countySn = undefined
  408. if (val) {
  409. this.getArea('city', val)
  410. }
  411. },
  412. // 获取区县列表
  413. getAreaList (val) {
  414. this.addrDistrictList = []
  415. this.queryParam.countySn = undefined
  416. if (val) {
  417. this.getArea('district', val)
  418. }
  419. },
  420. // 省/市/区
  421. getArea (leve, sn) {
  422. let params
  423. if (leve == 'province') {
  424. params = { type: '2' }
  425. } else {
  426. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  427. }
  428. getArea(params).then(res => {
  429. if (res.status == 200) {
  430. if (leve == 'province') {
  431. this.addrProvinceList = res.data || []
  432. } else if (leve == 'city') {
  433. this.addrCityList = res.data || []
  434. } else if (leve == 'district') {
  435. this.addrDistrictList = res.data || []
  436. }
  437. } else {
  438. if (leve == 'province') {
  439. this.addrProvinceList = []
  440. } else if (leve == 'city') {
  441. this.addrCityList = []
  442. } else if (leve == 'district') {
  443. this.addrDistrictList = []
  444. }
  445. }
  446. })
  447. },
  448. pageInit () {
  449. this.getLinkageGroup()
  450. this.getArea('province')
  451. this.getCustTypeList()
  452. this.getWarehouseCascade()
  453. }
  454. },
  455. mounted () {
  456. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  457. this.pageInit()
  458. this.resetSearchForm()
  459. }
  460. },
  461. activated () {
  462. // 如果是新页签打开,则重置当前页面
  463. if (this.$store.state.app.isNewTab) {
  464. this.pageInit()
  465. this.resetSearchForm()
  466. }
  467. },
  468. beforeRouteEnter (to, from, next) {
  469. next(vm => {})
  470. }
  471. }
  472. </script>