list.vue 18 KB

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