list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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="chainSalesReportList-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="chainSalesReportList-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. <custList id="chainSalesReportList-salesTargetName" ref="custSatelliteList" @change="custSatelliteChange"></custList>
  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="chainSalesReportList-salesTargetType" 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="chainSalesReportList-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. <a-input id="chainSalesReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入单号"/>
  63. </a-form-model-item>
  64. </a-col>
  65. <a-col :md="6" :sm="24">
  66. <a-form-model-item label="业务员">
  67. <a-input id="chainSalesReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
  68. </a-form-model-item>
  69. </a-col>
  70. <a-col :md="12" :sm="24">
  71. <a-row>
  72. <a-form-model-item label="客户所在区" :labelCol="{span: 4}" :wrapperCol="{ span: 20 }" style="margin-bottom: 0!important;">
  73. <a-col span="8">
  74. <a-form-model-item prop="provinceSn" style="margin: 0;">
  75. <a-select v-model="queryParam.provinceSn" allowClear @change="getCityList" placeholder="请选择省">
  76. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  77. </a-select>
  78. </a-form-model-item>
  79. </a-col>
  80. <a-col span="7" offset="1">
  81. <a-form-model-item prop="citySn" style="margin: 0;">
  82. <a-select v-model="queryParam.citySn" allowClear @change="getAreaList" placeholder="请选择市">
  83. <a-select-option v-for="item in addrCityList" :value="item.areaSn" :key="item.areaSn + 'b'">{{ item.name }}</a-select-option>
  84. </a-select>
  85. </a-form-model-item>
  86. </a-col>
  87. <a-col span="7" offset="1">
  88. <a-form-model-item prop="countySn" style="margin: 0;">
  89. <a-select v-model="queryParam.countySn" allowClear placeholder="请选择区/县">
  90. <a-select-option v-for="item in addrDistrictList" :value="item.areaSn" :key="item.areaSn + 'c'">{{ item.name }}</a-select-option>
  91. </a-select>
  92. </a-form-model-item>
  93. </a-col>
  94. </a-form-model-item>
  95. </a-row>
  96. </a-col>
  97. </template>
  98. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  99. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainSalesReportList-refresh">查询</a-button>
  100. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainSalesReportList-reset">重置</a-button>
  101. <a @click="advanced=!advanced" style="margin-left: 8px">
  102. {{ advanced ? '收起' : '展开' }}
  103. <a-icon :type="advanced ? 'up' : 'down'"/>
  104. </a>
  105. </a-col>
  106. </a-row>
  107. </a-form-model>
  108. </div>
  109. <!-- 合计 -->
  110. <a-alert type="info" style="margin-bottom:10px">
  111. <div class="ftext" slot="message">
  112. 总单数:<strong>{{ (totalData && (totalData.totalRowSize || totalData.totalRowSize==0)) ? totalData.totalRowSize : '--' }}</strong>;
  113. 产品总数量:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
  114. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  115. 总成本:<strong>{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? toThousands(totalData.totalCost) : '--' }}</strong>;
  116. </div>
  117. 总售价:<strong>{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? toThousands(totalData.totalAmount) : '--' }}</strong>;
  118. 折后总售价:<strong>{{ (totalData && (totalData.discountedAmount || totalData.discountedAmount==0)) ? toThousands(totalData.discountedAmount) : '--' }}</strong>;
  119. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  120. 总毛利:<strong>{{ (totalData && (totalData.totalProfit || totalData.totalProfit==0)) ? toThousands(totalData.totalProfit) : '--' }}</strong>。
  121. </div>
  122. </div>
  123. </a-alert>
  124. <!-- 列表 -->
  125. <s-table
  126. class="sTable"
  127. ref="table"
  128. size="small"
  129. :rowKey="(record) => record.id"
  130. :columns="columns"
  131. :data="loadData"
  132. :defaultLoadData="false"
  133. bordered>
  134. </s-table>
  135. </a-spin>
  136. </template>
  137. <script>
  138. import { commonMixin } from '@/utils/mixin'
  139. import { STable, VSelect } from '@/components'
  140. import rangeDate from '@/views/common/rangeDate.vue'
  141. import { getArea } from '@/api/data'
  142. import { custTypeFindAllList } from '@/api/custType'
  143. import custList from '@/views/common/custList.vue'
  144. import { reportChainSalesBillList, reportChainSalesBillCount, linkageGroupList } from '@/api/reportData'
  145. export default {
  146. components: { STable, VSelect, rangeDate, custList },
  147. mixins: [commonMixin],
  148. data () {
  149. return {
  150. spinning: false,
  151. labelCol: { span: 8 },
  152. wrapperCol: { span: 16 },
  153. advanced: false, // 高级搜索 展开/关闭
  154. tableHeight: 0,
  155. queryParam: { // 查询条件
  156. tenantId: undefined,
  157. time: [],
  158. beginDate: '',
  159. endDate: '',
  160. buyerNameCurrent: undefined,
  161. buyerSnCurrent: undefined,
  162. salesTargetType: undefined,
  163. provinceSn: undefined, // 省
  164. citySn: undefined, // 市
  165. countySn: undefined, // 区
  166. settleStyleSn: undefined,
  167. salesBillNo: '',
  168. salesManName: ''
  169. },
  170. rules: {
  171. 'tenantId': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
  172. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  173. },
  174. disabled: false, // 查询、重置按钮是否可操作
  175. exportLoading: false,
  176. // 加载数据方法 必须为 Promise 对象
  177. loadData: parameter => {
  178. this.disabled = true
  179. const params = Object.assign(parameter, this.queryParam)
  180. this.spinning = true
  181. delete params.time
  182. return reportChainSalesBillList(params).then(res => {
  183. let data
  184. if (res.status == 200) {
  185. data = res.data
  186. // 总计
  187. this.getCount(params)
  188. const no = (data.pageNo - 1) * data.pageSize
  189. for (var i = 0; i < data.list.length; i++) {
  190. data.list[i].no = no + i + 1
  191. }
  192. this.disabled = false
  193. }
  194. this.spinning = false
  195. return data
  196. })
  197. },
  198. totalData: null, // 合计
  199. linkageGroupData: [],
  200. addrProvinceList: [], // 省下拉
  201. addrCityList: [], // 市下拉
  202. addrDistrictList: [], // 区下拉
  203. allocateTypeList: [], // 调拨类型
  204. custTypeList: [] // 客户类型 下拉数据
  205. }
  206. },
  207. computed: {
  208. columns () {
  209. const _this = this
  210. const arr = [
  211. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  212. { title: '销售单号', dataIndex: 'salesBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  213. { title: '客户名称', dataIndex: 'salesTargetName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  214. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  215. { title: '款数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  216. { title: '数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  217. // { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  218. { title: '总售价', dataIndex: 'totalAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  219. { title: '折扣金额', dataIndex: 'discountAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  220. { title: '折后总售价', dataIndex: 'discountedAmount', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  221. // { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  222. { title: '业务员', dataIndex: 'salesManName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  223. { title: '审核时间', dataIndex: 'salesAuditDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } }
  224. ]
  225. if (this.$hasPermissions('M_ShowAllCost')) {
  226. arr.splice(6, 0, { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  227. arr.splice(10, 0, { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  228. }
  229. return arr
  230. }
  231. },
  232. methods: {
  233. // 合计
  234. getCount (params) {
  235. reportChainSalesBillCount(params).then(res => {
  236. if (res.status == 200) {
  237. this.totalData = res.data
  238. } else {
  239. this.totalData = null
  240. }
  241. })
  242. },
  243. // 创建时间 change
  244. dateChange (date) {
  245. this.queryParam.time = date
  246. this.queryParam.beginDate = date[0] || ''
  247. this.queryParam.endDate = date[1] || ''
  248. },
  249. // 查询
  250. handleSearch () {
  251. this.$refs.ruleForm.validate(valid => {
  252. if (valid) {
  253. this.$refs.table.refresh(true)
  254. } else {
  255. console.log('error submit!!')
  256. return false
  257. }
  258. })
  259. },
  260. custSatelliteChange (v, row) {
  261. if (row && row.customerSn) {
  262. this.queryParam.buyerSnCurrent = row.customerSn
  263. this.queryParam.buyerNameCurrent = undefined
  264. } else {
  265. this.queryParam.buyerNameCurrent = v
  266. this.queryParam.buyerSnCurrent = undefined
  267. }
  268. },
  269. // 重置
  270. resetSearchForm () {
  271. this.queryParam.tenantId = undefined
  272. this.$refs.rangeDate.resetDate()
  273. this.queryParam.time = []
  274. this.queryParam.beginDate = ''
  275. this.queryParam.endDate = ''
  276. this.queryParam.buyerNameCurrent = undefined
  277. this.queryParam.buyerSnCurrent = undefined
  278. this.queryParam.salesTargetType = undefined
  279. this.queryParam.provinceSn = undefined
  280. this.queryParam.citySn = undefined
  281. this.queryParam.countySn = undefined
  282. this.queryParam.settleStyleSn = undefined
  283. this.queryParam.salesBillNo = ''
  284. this.queryParam.salesManName = ''
  285. this.$refs.custSatelliteList.resetForm()
  286. this.$refs.ruleForm.resetFields()
  287. this.totalData = null
  288. this.$refs.table.clearTable()
  289. },
  290. filterOption (input, option) {
  291. return (
  292. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  293. )
  294. },
  295. // 获取客户类型列表
  296. getCustTypeList () {
  297. const _this = this
  298. custTypeFindAllList().then(res => {
  299. if (res.status == 200) {
  300. _this.custTypeList = res.data || []
  301. } else {
  302. _this.custTypeList = []
  303. }
  304. })
  305. },
  306. // 连锁店
  307. getLinkageGroup () {
  308. linkageGroupList({}).then(res => {
  309. if (res.status == 200) {
  310. const data = res.data || []
  311. if (data.length > 0) {
  312. this.linkageGroupData = data
  313. } else {
  314. this.linkageGroupData = []
  315. }
  316. } else {
  317. this.linkageGroupData = []
  318. }
  319. })
  320. },
  321. // 获取城市列表
  322. getCityList (val) {
  323. this.addrCityList = []
  324. this.addrDistrictList = []
  325. this.queryParam.citySn = undefined
  326. this.queryParam.countySn = undefined
  327. if (val) {
  328. this.getArea('city', val)
  329. }
  330. },
  331. // 获取区县列表
  332. getAreaList (val) {
  333. this.addrDistrictList = []
  334. this.queryParam.countySn = undefined
  335. if (val) {
  336. this.getArea('district', val)
  337. }
  338. },
  339. // 省/市/区
  340. getArea (leve, sn) {
  341. let params
  342. if (leve == 'province') {
  343. params = { type: '2' }
  344. } else {
  345. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  346. }
  347. getArea(params).then(res => {
  348. if (res.status == 200) {
  349. if (leve == 'province') {
  350. this.addrProvinceList = res.data || []
  351. } else if (leve == 'city') {
  352. this.addrCityList = res.data || []
  353. } else if (leve == 'district') {
  354. this.addrDistrictList = res.data || []
  355. }
  356. } else {
  357. if (leve == 'province') {
  358. this.addrProvinceList = []
  359. } else if (leve == 'city') {
  360. this.addrCityList = []
  361. } else if (leve == 'district') {
  362. this.addrDistrictList = []
  363. }
  364. }
  365. })
  366. },
  367. pageInit () {
  368. this.getLinkageGroup()
  369. this.getArea('province')
  370. this.getCustTypeList()
  371. }
  372. },
  373. mounted () {
  374. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  375. this.pageInit()
  376. this.resetSearchForm()
  377. }
  378. },
  379. activated () {
  380. // 如果是新页签打开,则重置当前页面
  381. if (this.$store.state.app.isNewTab) {
  382. this.pageInit()
  383. this.resetSearchForm()
  384. }
  385. },
  386. beforeRouteEnter (to, from, next) {
  387. next(vm => {})
  388. }
  389. }
  390. </script>