list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <div class="jg-page-wrap">
  3. <a-card size="small" :bordered="false" class="table-page-search-wrapper">
  4. <!-- 搜索条件 -->
  5. <a-form-model
  6. id="salesProfit-form"
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :model="queryParam"
  11. :labelCol="labelCol"
  12. :wrapperCol="wrapperCol"
  13. @keyup.enter.native="handleSearch" >
  14. <a-row :gutter="15">
  15. <a-col :md="6" :sm="24">
  16. <a-form-model-item label="创建时间">
  17. <rangeDate id="salesProfit-creatDate" ref="creatDate" v-model="creatTime" @change="creatDateChange" />
  18. </a-form-model-item>
  19. </a-col>
  20. <a-col :md="6" :sm="24">
  21. <a-form-model-item label="客户名称">
  22. <custList id="salesProfit-buyerName" ref="custSatelliteList" @change="custSatelliteChange"></custList>
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-item label="客户类型">
  27. <custType id="salesProfit-salesTargetType" v-model="queryParam.salesTargetType" allowClear placeholder="请选择客户类型"></custType>
  28. </a-form-item>
  29. </a-col>
  30. <template v-if="advanced">
  31. <a-col :md="6" :sm="24">
  32. <a-form-model-item label="收款方式">
  33. <v-select
  34. code="SETTLE_STYLE"
  35. id="salesProfit-settleStyleSn"
  36. v-model="queryParam.settleStyleSn"
  37. allowClear
  38. placeholder="请选择收款方式"
  39. ></v-select>
  40. </a-form-model-item>
  41. </a-col>
  42. <a-col :md="6" :sm="24">
  43. <a-form-model-item label="审核时间">
  44. <rangeDate id="salesProfit-rangeDate" ref="rangeDate" v-model="time" @change="dateChange" />
  45. </a-form-model-item>
  46. </a-col>
  47. <a-col :md="6" :sm="24">
  48. <a-form-model-item label="业务员">
  49. <a-input id="salesProfit-manName" v-model.trim="queryParam.manName" allowClear placeholder="请输入业务员"/>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col :md="6" :sm="24">
  53. <a-form-model-item label="单号">
  54. <a-input id="salesProfit-billNo" v-model.trim="queryParam.billNo" allowClear placeholder="请输入单号"/>
  55. </a-form-model-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-item label="客户所在区">
  59. <AreaList id="salesProfit-areaList" changeOnSelect ref="areaList" @change="areaChange"></AreaList>
  60. </a-form-item>
  61. </a-col>
  62. <a-col :md="6" :sm="24">
  63. <a-form-item label="单据类型">
  64. <a-select id="salesProfit-billType" v-model="queryParam.billType" allowClear placeholder="请选择单据类型">
  65. <a-select-option value="SALES_BILL">销售</a-select-option>
  66. <a-select-option value="SALES_RETURN">销售退货</a-select-option>
  67. </a-select>
  68. </a-form-item>
  69. </a-col>
  70. <a-col :md="6" :sm="24">
  71. <a-form-model-item label="客户关系">
  72. <v-select code="CUSTOMER_RELATION_TYPE" id="salesProfit-customerRelationType" v-model="queryParam.customerRelationType" allowClear placeholder="请选择客户关系"></v-select>
  73. </a-form-model-item>
  74. </a-col>
  75. <a-col :md="6" :sm="24">
  76. <a-form-item label="急件">
  77. <v-select
  78. v-model="queryParam.urgentBillStatus"
  79. ref="status"
  80. id="salesProfit-status"
  81. code="URGENT_STATUS"
  82. placeholder="请选择急件状态"
  83. allowClear></v-select>
  84. </a-form-item>
  85. </a-col>
  86. </template>
  87. <a-col :md="6" :sm="24">
  88. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesProfit-refresh">查询</a-button>
  89. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesProfit-reset">重置</a-button>
  90. <a-button
  91. type="primary"
  92. style="margin-left: 5px"
  93. @click="handleExport"
  94. :disabled="disabled"
  95. :loading="exportLoading"
  96. v-if="$hasPermissions('M_salesProfitExport')"
  97. class="button-warning"
  98. id="salesProfit-export-btn">导出</a-button>
  99. <a @click="advanced=!advanced" style="margin-left: 5px" id="salesProfit-advanced">
  100. {{ advanced ? '收起' : '展开' }}
  101. <a-icon :type="advanced ? 'up' : 'down'"/>
  102. </a>
  103. </a-col>
  104. </a-row>
  105. </a-form-model>
  106. </a-card>
  107. <a-card size="small" :bordered="false">
  108. <!-- 合计 -->
  109. <a-alert type="info" style="margin-bottom:10px">
  110. <div class="ftext" slot="message">
  111. 总单数:<strong>{{ (totalData && (totalData.totalRecord || totalData.totalRecord==0)) ? totalData.totalRecord : '--' }}</strong>;
  112. 产品总数量:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
  113. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  114. 总成本:<strong>{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? toThousands(totalData.totalCost) : '--' }}</strong>;
  115. </div>
  116. 总售价:<strong>{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? toThousands(totalData.totalAmount) : '--' }}</strong>;
  117. 折后总售价:<strong>{{ (totalData && (totalData.discountedAmount || totalData.discountedAmount==0)) ? toThousands(totalData.discountedAmount) : '--' }}</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. <a-spin :spinning="spinning" tip="Loading...">
  125. <s-table
  126. class="sTable"
  127. ref="table"
  128. size="small"
  129. :rowKey="(record) => record.no"
  130. rowKeyName="no"
  131. :columns="columns"
  132. :data="loadData"
  133. :defaultLoadData="false"
  134. bordered>
  135. </s-table>
  136. </a-spin>
  137. </a-card>
  138. </div>
  139. </template>
  140. <script>
  141. import { commonMixin } from '@/utils/mixin'
  142. import { STable, VSelect } from '@/components'
  143. import rangeDate from '@/views/common/rangeDate.vue'
  144. import { downloadExcel } from '@/libs/JGPrint.js'
  145. import custType from '@/views/common/custType.js'
  146. import AreaList from '@/views/common/areaList.js'
  147. import custList from '@/views/common/custList.vue'
  148. import { reportSalesProfitList, reportSalesProfitCount, reportSalesProfitExport } from '@/api/reportData'
  149. export default {
  150. components: { STable, VSelect, rangeDate, custList, AreaList, custType },
  151. mixins: [commonMixin],
  152. data () {
  153. return {
  154. spinning: false,
  155. labelCol: { span: 8 },
  156. wrapperCol: { span: 16 },
  157. advanced: false, // 高级搜索 展开/关闭
  158. tableHeight: 0,
  159. queryParam: { // 查询条件
  160. createBeginDate: '', // 创建开始时间
  161. createEndDate: '', // 创建结束时间
  162. beginDate: '', // 审核开始时间
  163. endDate: '', // 审核结束时间
  164. buyerName: undefined, // 客户名称
  165. buyerSn: undefined, // 客户sn
  166. salesTargetType: undefined, // 客户类型
  167. provinceSn: undefined, // 省
  168. citySn: undefined, // 市
  169. countySn: undefined, // 区
  170. settleStyleSn: undefined, // 收款方式
  171. billNo: '', // 单号
  172. manName: '', // 销售人员
  173. billType: undefined, // 单据类型
  174. customerRelationType: undefined, // 客户关系
  175. urgentBillStatus: undefined // 急件状态
  176. },
  177. creatTime: [], // 创建时间
  178. time: [], // 审核时间
  179. disabled: false, // 查询、重置按钮是否可操作
  180. exportLoading: false,
  181. // 加载数据方法 必须为 Promise 对象
  182. loadData: parameter => {
  183. this.disabled = true
  184. const params = Object.assign(parameter, this.queryParam)
  185. this.spinning = true
  186. delete params.time
  187. return reportSalesProfitList(params).then(res => {
  188. let data
  189. if (res.status == 200) {
  190. data = res.data
  191. // 总计
  192. this.getCount(params)
  193. const no = (data.pageNo - 1) * data.pageSize
  194. for (var i = 0; i < data.list.length; i++) {
  195. data.list[i].no = no + i + 1
  196. }
  197. this.disabled = false
  198. }
  199. this.spinning = false
  200. return data
  201. })
  202. },
  203. totalData: null, // 合计
  204. addrProvinceList: [], // 省下拉
  205. addrCityList: [], // 市下拉
  206. addrDistrictList: [], // 区下拉
  207. allocateTypeList: [], // 调拨类型
  208. custTypeList: [] // 客户类型 下拉数据
  209. }
  210. },
  211. computed: {
  212. columns () {
  213. const _this = this
  214. const arr = [
  215. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  216. { title: '单号', dataIndex: 'billNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  217. { title: '急件', dataIndex: 'urgentBillStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  218. { title: '客户名称', dataIndex: 'buyerName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  219. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  220. { title: '款数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  221. { title: '数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  222. // { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  223. { title: '总售价', dataIndex: 'totalAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  224. { title: '折扣金额', dataIndex: 'discountAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  225. { title: '折后总售价', dataIndex: 'discountedAmount', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  226. // { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  227. { title: '业务员', dataIndex: 'manName', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  228. { title: '审核时间', dataIndex: 'auditDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  229. ]
  230. if (this.$hasPermissions('M_ShowAllCost')) {
  231. arr.splice(7, 0, { title: '总成本', dataIndex: 'totalCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  232. arr.splice(11, 0, { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  233. }
  234. return arr
  235. }
  236. },
  237. methods: {
  238. // 所在区域
  239. areaChange (val) {
  240. this.queryParam.provinceSn = val[0] ? val[0] : undefined
  241. this.queryParam.citySn = val[1] ? val[1] : undefined
  242. this.queryParam.countySn = val[2] ? val[2] : undefined
  243. },
  244. // 合计
  245. getCount (params) {
  246. reportSalesProfitCount(params).then(res => {
  247. if (res.status == 200) {
  248. this.totalData = res.data
  249. } else {
  250. this.totalData = null
  251. }
  252. })
  253. },
  254. // 创建时间
  255. creatDateChange (date) {
  256. this.creatTime = date
  257. this.queryParam.createBeginDate = date[0] || ''
  258. this.queryParam.createEndDate = date[1] || ''
  259. },
  260. // 创建时间 change
  261. dateChange (date) {
  262. this.time = date
  263. this.queryParam.beginDate = date[0] || ''
  264. this.queryParam.endDate = date[1] || ''
  265. },
  266. // 查询
  267. handleSearch () {
  268. let hasVal = false
  269. for (const key in this.queryParam) {
  270. if (this.queryParam[key]) {
  271. hasVal = true
  272. break
  273. }
  274. }
  275. if (hasVal) {
  276. this.$refs.table.refresh(true)
  277. } else {
  278. this.$message.info('请至少输入一个查询条件')
  279. }
  280. },
  281. // 客户名称
  282. custSatelliteChange (v, row) {
  283. if (row && row.customerSn) {
  284. this.queryParam.buyerSn = row.customerSn
  285. this.queryParam.buyerName = undefined
  286. } else {
  287. this.queryParam.buyerName = v
  288. this.queryParam.buyerSn = undefined
  289. }
  290. },
  291. // 重置
  292. resetSearchForm () {
  293. this.$refs.creatDate.resetDate()
  294. this.creatTime = []
  295. this.queryParam.createBeginDate = ''
  296. this.queryParam.createEndDate = ''
  297. this.queryParam.buyerName = undefined
  298. this.queryParam.buyerSn = undefined
  299. this.queryParam.salesTargetType = undefined
  300. this.queryParam.provinceSn = undefined
  301. this.queryParam.citySn = undefined
  302. this.queryParam.countySn = undefined
  303. this.queryParam.settleStyleSn = undefined
  304. this.queryParam.showCost = undefined
  305. this.queryParam.billNo = ''
  306. this.queryParam.manName = ''
  307. this.queryParam.billType = undefined
  308. this.queryParam.customerRelationType = undefined// 客户关系
  309. this.queryParam.urgentBillStatus = undefined // 急件状态
  310. this.$refs.ruleForm.resetFields()
  311. this.totalData = null
  312. if (this.advanced) {
  313. this.$refs.rangeDate.resetDate()
  314. this.time = []
  315. this.queryParam.beginDate = ''
  316. this.queryParam.endDate = ''
  317. this.$refs.custSatelliteList.resetForm()
  318. this.$refs.areaList.clearData()
  319. }
  320. this.$refs.table.clearTable()
  321. },
  322. // 导出
  323. handleExport () {
  324. const _this = this
  325. let hasVal = false
  326. for (const key in this.queryParam) {
  327. if (this.queryParam[key]) {
  328. hasVal = true
  329. break
  330. }
  331. }
  332. if (hasVal) {
  333. const params = _this.queryParam
  334. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  335. _this.exportLoading = true
  336. _this.spinning = true
  337. reportSalesProfitExport(params).then(res => {
  338. downloadExcel(res, '销售报表')
  339. _this.exportLoading = false
  340. _this.spinning = false
  341. _this.queryParam.showCost = undefined
  342. })
  343. } else {
  344. this.$message.info('请至少输入一个查询条件')
  345. }
  346. }
  347. },
  348. mounted () {
  349. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  350. this.resetSearchForm()
  351. }
  352. },
  353. activated () {
  354. // 如果是新页签打开,则重置当前页面
  355. if (this.$store.state.app.isNewTab) {
  356. this.resetSearchForm()
  357. }
  358. },
  359. beforeRouteEnter (to, from, next) {
  360. next(vm => {})
  361. }
  362. }
  363. </script>