list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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-item label="客户类型">
  44. <custType v-model="queryParam.salesTargetType" allowClear placeholder="请选择客户类型"></custType>
  45. </a-form-item>
  46. </a-col>
  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-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入单号"/>
  61. </a-form-model-item>
  62. </a-col>
  63. <a-col :md="6" :sm="24">
  64. <a-form-model-item label="业务员">
  65. <a-input id="chainSalesReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
  66. </a-form-model-item>
  67. </a-col>
  68. <a-col :md="6" :sm="24">
  69. <a-form-item label="客户所在区">
  70. <AreaList changeOnSelect ref="areaList" @change="areaChange"></AreaList>
  71. </a-form-item>
  72. </a-col>
  73. </template>
  74. <a-col :md="6" :sm="24" style="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">
  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. areaChange (val) {
  210. this.queryParam.provinceSn = val[0] ? val[0] : undefined
  211. this.queryParam.citySn = val[1] ? val[1] : undefined
  212. this.queryParam.countySn = val[2] ? val[2] : undefined
  213. },
  214. // 合计
  215. getCount (params) {
  216. reportChainSalesBillCount(params).then(res => {
  217. if (res.status == 200) {
  218. this.totalData = res.data
  219. } else {
  220. this.totalData = null
  221. }
  222. })
  223. },
  224. // 创建时间 change
  225. dateChange (date) {
  226. this.queryParam.time = date
  227. this.queryParam.beginDate = date[0] || ''
  228. this.queryParam.endDate = date[1] || ''
  229. },
  230. // 查询
  231. handleSearch () {
  232. this.$refs.ruleForm.validate(valid => {
  233. if (valid) {
  234. this.$refs.table.refresh(true)
  235. } else {
  236. console.log('error submit!!')
  237. return false
  238. }
  239. })
  240. },
  241. custSatelliteChange (v, row) {
  242. if (row && row.customerSn) {
  243. this.queryParam.buyerSnCurrent = row.customerSn
  244. this.queryParam.buyerNameCurrent = undefined
  245. } else {
  246. this.queryParam.buyerNameCurrent = v
  247. this.queryParam.buyerSnCurrent = undefined
  248. }
  249. },
  250. // 重置
  251. resetSearchForm () {
  252. this.queryParam.tenantId = undefined
  253. this.$refs.rangeDate.resetDate()
  254. this.queryParam.time = []
  255. this.queryParam.beginDate = ''
  256. this.queryParam.endDate = ''
  257. this.queryParam.buyerNameCurrent = undefined
  258. this.queryParam.buyerSnCurrent = undefined
  259. this.queryParam.salesTargetType = undefined
  260. this.queryParam.provinceSn = undefined
  261. this.queryParam.citySn = undefined
  262. this.queryParam.countySn = undefined
  263. this.queryParam.settleStyleSn = undefined
  264. this.queryParam.salesBillNo = ''
  265. this.queryParam.salesManName = ''
  266. this.$refs.custSatelliteList.resetForm()
  267. if(this.advanced){
  268. this.$refs.areaList.clearData()
  269. }
  270. this.$refs.ruleForm.resetFields()
  271. this.totalData = null
  272. this.$refs.table.clearTable()
  273. },
  274. filterOption (input, option) {
  275. return (
  276. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  277. )
  278. },
  279. // 连锁店
  280. getLinkageGroup () {
  281. linkageGroupList({}).then(res => {
  282. if (res.status == 200) {
  283. const data = res.data || []
  284. if (data.length > 0) {
  285. this.linkageGroupData = data
  286. } else {
  287. this.linkageGroupData = []
  288. }
  289. } else {
  290. this.linkageGroupData = []
  291. }
  292. })
  293. },
  294. pageInit () {
  295. this.getLinkageGroup()
  296. }
  297. },
  298. mounted () {
  299. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  300. this.pageInit()
  301. this.resetSearchForm()
  302. }
  303. },
  304. activated () {
  305. // 如果是新页签打开,则重置当前页面
  306. if (this.$store.state.app.isNewTab) {
  307. this.pageInit()
  308. this.resetSearchForm()
  309. }
  310. },
  311. beforeRouteEnter (to, from, next) {
  312. next(vm => {})
  313. }
  314. }
  315. </script>