list.vue 14 KB

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