list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  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. <a-input id="chainSalesReportList-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="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.totalPrice || totalData.totalPrice==0)) ? toThousands(totalData.totalPrice) : '--' }}</strong>;
  118. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  119. 总毛利:<strong>{{ (totalData && (totalData.totalProfit || totalData.totalProfit==0)) ? toThousands(totalData.totalProfit) : '--' }}</strong>。
  120. </div>
  121. </div>
  122. </a-alert>
  123. <!-- 列表 -->
  124. <s-table
  125. class="sTable"
  126. ref="table"
  127. size="small"
  128. :rowKey="(record) => record.id"
  129. :columns="columns"
  130. :data="loadData"
  131. :defaultLoadData="false"
  132. bordered>
  133. </s-table>
  134. </a-spin>
  135. </template>
  136. <script>
  137. import { commonMixin } from '@/utils/mixin'
  138. import { STable, VSelect } from '@/components'
  139. import rangeDate from '@/views/common/rangeDate.vue'
  140. import { getArea } from '@/api/data'
  141. import { custTypeFindAllList } from '@/api/custType'
  142. import { reportChainSalesBillList, reportChainSalesBillCount, linkageGroupList } from '@/api/reportData'
  143. export default {
  144. components: { STable, VSelect, rangeDate },
  145. mixins: [commonMixin],
  146. data () {
  147. return {
  148. spinning: false,
  149. labelCol: { span: 8 },
  150. wrapperCol: { span: 16 },
  151. advanced: false, // 高级搜索 展开/关闭
  152. tableHeight: 0,
  153. queryParam: { // 查询条件
  154. tenantId: undefined,
  155. time: [],
  156. beginDate: '',
  157. endDate: '',
  158. salesTargetName: '',
  159. salesTargetType: undefined,
  160. provinceSn: undefined, // 省
  161. citySn: undefined, // 市
  162. countySn: undefined, // 区
  163. settleStyleSn: undefined,
  164. salesBillNo: '',
  165. salesManName: ''
  166. },
  167. rules: {
  168. 'tenantId': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
  169. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  170. },
  171. disabled: false, // 查询、重置按钮是否可操作
  172. exportLoading: false,
  173. // 加载数据方法 必须为 Promise 对象
  174. loadData: parameter => {
  175. this.disabled = true
  176. const params = Object.assign(parameter, this.queryParam)
  177. this.spinning = true
  178. delete params.time
  179. return reportChainSalesBillList(params).then(res => {
  180. let data
  181. if (res.status == 200) {
  182. data = res.data
  183. // 总计
  184. this.getCount(params)
  185. const no = (data.pageNo - 1) * data.pageSize
  186. for (var i = 0; i < data.list.length; i++) {
  187. data.list[i].no = no + i + 1
  188. }
  189. this.disabled = false
  190. }
  191. this.spinning = false
  192. return data
  193. })
  194. },
  195. totalData: null, // 合计
  196. linkageGroupData: [],
  197. addrProvinceList: [], // 省下拉
  198. addrCityList: [], // 市下拉
  199. addrDistrictList: [], // 区下拉
  200. allocateTypeList: [], // 调拨类型
  201. custTypeList: [] // 客户类型 下拉数据
  202. }
  203. },
  204. computed: {
  205. columns () {
  206. const _this = this
  207. const arr = [
  208. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  209. { title: '销售单号', dataIndex: 'salesBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  210. { title: '客户名称', dataIndex: 'salesTargetName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  211. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  212. { title: '款数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  213. { title: '数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  214. // { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  215. { title: '售价', dataIndex: 'totalPrice', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  216. // { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  217. { title: '业务员', dataIndex: 'salesManName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  218. { title: '审核时间', dataIndex: 'salesAuditDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } }
  219. ]
  220. if (this.$hasPermissions('M_ShowAllCost')) {
  221. arr.splice(6, 0, { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  222. arr.splice(8, 0, { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  223. }
  224. return arr
  225. }
  226. },
  227. methods: {
  228. // 合计
  229. getCount (params) {
  230. reportChainSalesBillCount(params).then(res => {
  231. if (res.status == 200) {
  232. this.totalData = res.data
  233. } else {
  234. this.totalData = null
  235. }
  236. })
  237. },
  238. // 创建时间 change
  239. dateChange (date) {
  240. this.queryParam.time = date
  241. this.queryParam.beginDate = date[0] || ''
  242. this.queryParam.endDate = date[1] || ''
  243. },
  244. // 查询
  245. handleSearch () {
  246. this.$refs.ruleForm.validate(valid => {
  247. if (valid) {
  248. this.$refs.table.refresh(true)
  249. } else {
  250. console.log('error submit!!')
  251. return false
  252. }
  253. })
  254. },
  255. // 重置
  256. resetSearchForm () {
  257. this.queryParam.tenantId = undefined
  258. this.$refs.rangeDate.resetDate()
  259. this.queryParam.time = []
  260. this.queryParam.beginDate = ''
  261. this.queryParam.endDate = ''
  262. this.queryParam.salesTargetName = ''
  263. this.queryParam.salesTargetType = undefined
  264. this.queryParam.provinceSn = undefined
  265. this.queryParam.citySn = undefined
  266. this.queryParam.countySn = undefined
  267. this.queryParam.settleStyleSn = undefined
  268. this.queryParam.salesBillNo = ''
  269. this.queryParam.salesManName = ''
  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. getCustTypeList () {
  281. const _this = this
  282. custTypeFindAllList().then(res => {
  283. if (res.status == 200) {
  284. _this.custTypeList = res.data || []
  285. } else {
  286. _this.custTypeList = []
  287. }
  288. })
  289. },
  290. // 连锁店
  291. getLinkageGroup () {
  292. linkageGroupList({}).then(res => {
  293. if (res.status == 200) {
  294. const data = res.data || []
  295. if (data.length > 0) {
  296. this.linkageGroupData = data
  297. } else {
  298. this.linkageGroupData = []
  299. }
  300. } else {
  301. this.linkageGroupData = []
  302. }
  303. })
  304. },
  305. // 获取城市列表
  306. getCityList (val) {
  307. this.addrCityList = []
  308. this.addrDistrictList = []
  309. this.queryParam.citySn = undefined
  310. this.queryParam.countySn = undefined
  311. if (val) {
  312. this.getArea('city', val)
  313. }
  314. },
  315. // 获取区县列表
  316. getAreaList (val) {
  317. this.addrDistrictList = []
  318. this.queryParam.countySn = undefined
  319. if (val) {
  320. this.getArea('district', val)
  321. }
  322. },
  323. // 省/市/区
  324. getArea (leve, sn) {
  325. let params
  326. if (leve == 'province') {
  327. params = { type: '2' }
  328. } else {
  329. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  330. }
  331. getArea(params).then(res => {
  332. if (res.status == 200) {
  333. if (leve == 'province') {
  334. this.addrProvinceList = res.data || []
  335. } else if (leve == 'city') {
  336. this.addrCityList = res.data || []
  337. } else if (leve == 'district') {
  338. this.addrDistrictList = res.data || []
  339. }
  340. } else {
  341. if (leve == 'province') {
  342. this.addrProvinceList = []
  343. } else if (leve == 'city') {
  344. this.addrCityList = []
  345. } else if (leve == 'district') {
  346. this.addrDistrictList = []
  347. }
  348. }
  349. })
  350. },
  351. pageInit () {
  352. this.getLinkageGroup()
  353. this.getArea('province')
  354. this.getCustTypeList()
  355. }
  356. },
  357. mounted () {
  358. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  359. this.pageInit()
  360. this.resetSearchForm()
  361. }
  362. },
  363. activated () {
  364. // 如果是新页签打开,则重置当前页面
  365. if (this.$store.state.app.isNewTab) {
  366. this.pageInit()
  367. this.resetSearchForm()
  368. }
  369. },
  370. beforeRouteEnter (to, from, next) {
  371. next(vm => {})
  372. }
  373. }
  374. </script>