list.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <a-card size="small" :bordered="false" class="salesManagementList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="创建时间">
  10. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="客户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  15. <dealerSubareaScopeList ref="dealerSubareaScopeList" id="salesManagementList-buyerName" @change="custChange" />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="销售单号">
  20. <a-input id="salesManagementList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  21. </a-form-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="采购单号">
  26. <a-input id="salesManagementList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="打印状态">
  31. <v-select
  32. v-model="queryParam.printStatus"
  33. ref="printStatus"
  34. id="salesManagementList-printStatus"
  35. code="PRINT_STATUS"
  36. placeholder="请选择打印状态"
  37. allowClear></v-select>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :md="6" :sm="24">
  41. <a-form-item label="业务状态">
  42. <v-select
  43. v-model="queryParam.billStatus"
  44. ref="billStatus"
  45. id="salesManagementList-billStatus"
  46. code="SALES_BILL_STATUS"
  47. placeholder="请选择业务状态"
  48. allowClear></v-select>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24">
  52. <a-form-item label="财务状态">
  53. <v-select
  54. v-model="queryParam.financialStatus"
  55. ref="financialStatus"
  56. id="salesManagementList-financialStatus"
  57. code="FINANCIAL_RECEIVE_STATUS"
  58. placeholder="请选择财务状态"
  59. allowClear></v-select>
  60. </a-form-item>
  61. </a-col>
  62. <a-col :md="6" :sm="24">
  63. <a-form-item label="单据来源">
  64. <v-select
  65. v-model="queryParam.salesBillSource"
  66. ref="salesBillSource"
  67. id="salesManagementList-salesBillSource"
  68. code="SALES_SOURCE"
  69. placeholder="请选择单据来源"
  70. allowClear></v-select>
  71. </a-form-item>
  72. </a-col>
  73. <a-col :md="6" :sm="24">
  74. <a-form-model-item label="所在区域">
  75. <subarea id="salesManagementList-subarea" v-model="queryParam.subareaSn"></subarea>
  76. </a-form-model-item>
  77. </a-col>
  78. <a-col :md="6" :sm="24">
  79. <a-form-model-item label="地区">
  80. <a-form-model-item prop="shippingAddrProvinceSn">
  81. <a-select id="salesManagementList-shippingAddrProvinceSn" allowClear v-model="queryParam.shippingAddrProvinceSn" placeholder="请选择省">
  82. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  83. </a-select>
  84. </a-form-model-item>
  85. </a-form-model-item>
  86. </a-col>
  87. </template>
  88. <a-col :md="6" :sm="24">
  89. <span class="table-page-search-submitButtons">
  90. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  91. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  92. <a @click="advanced=!advanced" style="margin-left: 8px">
  93. {{ advanced ? '收起' : '展开' }}
  94. <a-icon :type="advanced ? 'up' : 'down'"/>
  95. </a>
  96. </span>
  97. </a-col>
  98. </a-row>
  99. </a-form>
  100. </div>
  101. <!-- 操作按钮 -->
  102. <div class="table-operator">
  103. <a-button type="primary" class="button-error" v-if="$hasPermissions('B_salesAdd')" @click="handleAdd">新增</a-button>
  104. </div>
  105. <!-- alert -->
  106. <a-alert type="info" style="margin-bottom:10px">
  107. <div slot="message">
  108. <div style="display: flex;justify-content: space-between;align-items: center;">
  109. <div>
  110. <div>
  111. 总单数:<strong>{{ totalData&&(totalData.totalRecord || totalData.totalRecord==0) ? totalData.totalRecord : '--' }}</strong>;
  112. 总款数:<strong>{{ totalData&&(totalData.totalCategory || totalData.totalCategory==0) ? totalData.totalCategory : '--' }}</strong>;
  113. 总数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  114. 已下推数量:<strong>{{ totalData&&(totalData.totalPushedQty || totalData.totalPushedQty==0) ? totalData.totalPushedQty : '--' }}</strong>;
  115. 已发货数量:<strong>{{ totalData&&(totalData.totalDispatchQty || totalData.totalDispatchQty==0) ? totalData.totalDispatchQty : '--' }}</strong>;
  116. 已取消数量:<strong>{{ totalData&&(totalData.totalCancelQty || totalData.totalCancelQty==0) ? totalData.totalCancelQty : '--' }}</strong>;
  117. 待下推数量:<strong>{{ totalData&&(totalData.totalUnpushedQty || totalData.totalUnpushedQty==0) ? totalData.totalUnpushedQty : '--' }}</strong>;
  118. </div>
  119. <div>
  120. 总售价:<strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? totalData.totalAmount : '--' }}</strong>元;
  121. 已下推金额::<strong>{{ totalData&&(totalData.totalPushedAmount || totalData.totalPushedAmount==0) ? totalData.totalPushedAmount : '--' }}</strong>元;
  122. 已取消金额::<strong>{{ totalData&&(totalData.totalCancelAmount || totalData.totalCancelAmount==0) ? totalData.totalCancelAmount : '--' }}</strong>元;
  123. 待下推金额::<strong>{{ totalData&&(totalData.totalUnpushedAmount || totalData.totalUnpushedAmount==0) ? totalData.totalUnpushedAmount : '--' }}</strong>元;
  124. 已发货金额::<strong>{{ totalData&&(totalData.totalDispatchAmount || totalData.totalDispatchAmount==0) ? totalData.totalDispatchAmount : '--' }}</strong>元;
  125. </div>
  126. </div>
  127. <a-checkbox v-model="showCancelNum"><span style="display: inline-block;margin-top: 1px;">显示取消数量</span></a-checkbox>
  128. </div>
  129. </div>
  130. </a-alert>
  131. <!-- 列表 -->
  132. <s-table
  133. class="sTable fixPagination"
  134. ref="table"
  135. :style="{ height: tableHeight+102.5+'px' }"
  136. size="small"
  137. :rowKey="(record) => record.id"
  138. :columns="columns"
  139. :data="loadData"
  140. :scroll="{ y: tableHeight }"
  141. :defaultLoadData="false"
  142. bordered>
  143. <!-- 销售单号 -->
  144. <template slot="salesBillNo" slot-scope="text, record">
  145. <div v-if="$hasPermissions('B_salesDetail')">
  146. <a-badge :count="'改'+record.changeTimes" :offset="[16,-13]" v-if="record.changeTimes>0" class="badge-con-t">
  147. <span style="color: #00aaff;cursor: pointer;" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  148. </a-badge>
  149. <span v-else style="color: #00aaff;cursor: pointer;" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  150. </div>
  151. <div v-else>{{ record.salesBillNo }}</div>
  152. </template>
  153. <!-- 总数量 -->
  154. <template slot="totalQty" slot-scope="text, record">
  155. {{ record.totalQty }}
  156. </template>
  157. <!-- 操作 -->
  158. <template slot="action" slot-scope="text, record">
  159. <a-button
  160. size="small"
  161. type="link"
  162. class="button-warning"
  163. v-if="record.billStatus == 'WAIT_AUDIT'&&$hasPermissions('B_salesAudit')"
  164. @click="handleDetail(record)"
  165. >审核</a-button>
  166. <a-button
  167. size="small"
  168. type="link"
  169. class="button-warning"
  170. v-if="record.billStatus == 'WAIT_PUSH'&&$hasPermissions('B_salesDispatch')"
  171. @click="handleDispatch(record)"
  172. >下推</a-button>
  173. <a-button
  174. size="small"
  175. type="link"
  176. class="button-info"
  177. v-if="record.salesBillSource != 'PURCHASE' && (record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'AUDIT_REJECT')&&$hasPermissions('B_salesEdit')"
  178. @click="handleEdit(record)"
  179. >
  180. 编辑
  181. </a-button>
  182. <a-button
  183. size="small"
  184. type="link"
  185. class="button-info"
  186. v-if="record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT'||record.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesEdit')"
  187. @click="handleEdit(record)"
  188. >
  189. 改单
  190. </a-button>
  191. <a-button
  192. size="small"
  193. type="link"
  194. class="button-error"
  195. v-if="record.salesBillSource != 'PURCHASE' && (record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'AUDIT_REJECT')&&$hasPermissions('B_salesDel')"
  196. @click="handleDel(record)"
  197. >
  198. 删除
  199. </a-button>
  200. <a-button
  201. size="small"
  202. type="link"
  203. class="button-error"
  204. v-if="record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT'||record.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesDel')"
  205. @click="handleDel(record)"
  206. >
  207. 取消
  208. </a-button>
  209. <span v-if="!(record.billStatus == 'WAIT_AUDIT'&&$hasPermissions('B_salesAudit')) && !(record.billStatus == 'WAIT_PUSH'&&$hasPermissions('B_salesDispatch')) && !(record.salesBillSource != 'PURCHASE' && (record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'AUDIT_REJECT')&&$hasPermissions('B_salesEdit')) && !(record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT'||record.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesEdit')) && !(record.salesBillSource != 'PURCHASE' && (record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'AUDIT_REJECT')&&$hasPermissions('B_salesDel')) && !(record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT'||record.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesDel'))">--</span>
  210. </template>
  211. </s-table>
  212. </a-spin>
  213. <!-- 选择客户弹框 -->
  214. <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  215. </a-card>
  216. </template>
  217. <script>
  218. import moment from 'moment'
  219. import getDate from '@/libs/getDate.js'
  220. import subarea from '@/views/common/subarea.js'
  221. import { getArea } from '@/api/data'
  222. import rangeDate from '@/views/common/rangeDate.vue'
  223. import { STable, VSelect } from '@/components'
  224. import chooseCustomModal from './chooseCustomModal.vue'
  225. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  226. import { salesList, salesDel, salesCount } from '@/api/sales'
  227. import { findBySalesBillSn } from '@/api/dispatch'
  228. export default {
  229. name: 'TableList',
  230. components: { STable, VSelect, chooseCustomModal, dealerSubareaScopeList, rangeDate, subarea },
  231. data () {
  232. return {
  233. spinning: false,
  234. advanced: false, // 高级搜索 展开/关闭
  235. disabled: false, // 查询、重置按钮是否可操作
  236. openModal: false, // 选择客户弹框是否显示
  237. tableHeight: 0,
  238. time: [
  239. moment(getDate.getThreeMonthDays().starttime, 'YYYY-MM-DD'),
  240. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  241. ],
  242. // 查询参数
  243. queryParam: {
  244. beginDate: getDate.getThreeMonthDays().starttime,
  245. endDate: getDate.getCurrMonthDays().endtime,
  246. buyerSn: undefined, // 客户名称
  247. salesBillNo: '', // 销售单号
  248. purchaseBillNo: '',
  249. printStatus: undefined,
  250. billStatus: undefined, // 业务状态
  251. financialStatus: undefined, // 财务状态
  252. salesBillSource: undefined,
  253. subareaSn: undefined,
  254. shippingAddrProvinceSn: undefined
  255. },
  256. totalData: {
  257. totalAmount: 0,
  258. totalCategory: 0,
  259. totalQty: 0,
  260. totalRecord: 0,
  261. totalPushedQty: 0,
  262. totalDispatchQty: 0,
  263. totalCancelQty: 0,
  264. totalUnpushedQty: 0,
  265. totalPushedAmount: 0,
  266. totalCancelAmount: 0,
  267. totalUnpushedAmount: 0,
  268. totalDispatchAmount: 0
  269. },
  270. // 加载数据方法 必须为 Promise 对象
  271. loadData: parameter => {
  272. this.disabled = true
  273. this.spinning = true
  274. delete parameter.tableId
  275. delete parameter.index
  276. // 查询总计
  277. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  278. this.totalData = Object.assign(this.totalData, res.data || {})
  279. })
  280. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  281. const data = res.data
  282. const no = (data.pageNo - 1) * data.pageSize
  283. for (var i = 0; i < data.list.length; i++) {
  284. data.list[i].no = no + i + 1
  285. }
  286. this.disabled = false
  287. this.spinning = false
  288. return data
  289. })
  290. },
  291. addrProvinceList: [], // 省下拉
  292. showCancelNum: false // 是否显示取消数量和待下推数量
  293. }
  294. },
  295. computed: {
  296. columns () {
  297. const arr = [
  298. { title: '创建时间', dataIndex: 'createDate', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  299. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: '10%', align: 'center' },
  300. { title: '采购单号', dataIndex: 'purchaseBillNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  301. { title: '客户名称', dataIndex: 'buyerName', width: '9%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  302. { title: '总数量', dataIndex: 'totalQty', scopedSlots: { customRender: 'totalQty' }, width: '4%', align: 'center' },
  303. { title: '总售价', dataIndex: 'totalAmount', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  304. { title: '已下推数量', dataIndex: 'totalPushedQty', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  305. { title: '已发货数量', dataIndex: 'totalDispatchQty', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  306. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  307. { title: '审核时间', dataIndex: 'auditDate', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  308. { title: '最近备货时间', dataIndex: 'lastStockUpDate', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  309. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  310. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  311. { title: '打印次数', dataIndex: 'detailPrintTimes', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  312. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  313. ]
  314. if (this.showCancelNum) {
  315. arr.splice(9, 0, { title: '已取消数量', dataIndex: 'totalCancelQty', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  316. arr.splice(10, 0, { title: '待下推数量', dataIndex: 'totalUnpushedQty', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  317. }
  318. return arr
  319. }
  320. },
  321. methods: {
  322. // 时间 change
  323. dateChange (date) {
  324. this.queryParam.beginDate = date[0]
  325. this.queryParam.endDate = date[1]
  326. },
  327. custChange (val) {
  328. this.queryParam.buyerSn = val.key
  329. },
  330. // 新增
  331. handleAdd () {
  332. this.openModal = true
  333. },
  334. // 选择客户成功
  335. chooseCustomOk (data) {
  336. this.$router.push({ name: 'salesAdd', params: { sn: data.salesBillSn } })
  337. },
  338. // 下推
  339. handleDispatch (row) {
  340. this.spinning = true
  341. findBySalesBillSn({ salesBillSn: row.salesBillSn }).then(res => {
  342. this.spinning = false
  343. if (res.status == 200) {
  344. this.$router.push({ name: 'waitDispatch', params: { salesBillSn: row.salesBillSn, dispatchBillSn: res.data.dispatchBillSn } })
  345. }
  346. })
  347. },
  348. // 详情
  349. handleDetail (row) {
  350. this.$router.push({ name: 'salesDetail', params: { sn: row.salesBillSn } })
  351. },
  352. // 编辑
  353. handleEdit (row) {
  354. this.$router.push({ name: 'salesEdit', params: { sn: row.salesBillSn } })
  355. },
  356. // 删除
  357. handleDel (row) {
  358. const _this = this
  359. this.$confirm({
  360. title: '提示',
  361. content: row.salesBillSource == 'PURCHASE' ? '确认要取消吗?' : '确认要删除吗?',
  362. centered: true,
  363. closable: true,
  364. onOk () {
  365. _this.spinning = true
  366. salesDel({ salesBillSn: row.salesBillSn }).then(res => {
  367. if (res.status == 200) {
  368. _this.$message.success(res.message)
  369. _this.$refs.table.refresh()
  370. _this.spinning = false
  371. } else {
  372. _this.spinning = false
  373. }
  374. })
  375. }
  376. })
  377. },
  378. // 重置
  379. resetSearchForm () {
  380. this.$refs.rangeDate.resetDate(this.time)
  381. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  382. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  383. this.$refs.dealerSubareaScopeList.resetForm()
  384. this.queryParam.buyerSn = undefined
  385. this.queryParam.salesBillNo = ''
  386. this.queryParam.purchaseBillNo = ''
  387. this.queryParam.printStatus = undefined
  388. this.queryParam.billStatus = undefined
  389. this.queryParam.financialStatus = undefined
  390. this.queryParam.salesBillSource = undefined
  391. this.queryParam.subareaSn = undefined
  392. this.queryParam.shippingAddrProvinceSn = undefined
  393. this.$refs.table.refresh(true)
  394. },
  395. // 省/市/区
  396. getArea (leve, sn) {
  397. let params
  398. if (leve == 'province') {
  399. params = { type: '2' }
  400. } else {
  401. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  402. }
  403. getArea(params).then(res => {
  404. if (res.status == 200) {
  405. if (leve == 'province') {
  406. this.addrProvinceList = res.data || []
  407. } else if (leve == 'city') {
  408. this.addrCityList = res.data || []
  409. } else if (leve == 'district') {
  410. this.addrDistrictList = res.data || []
  411. }
  412. } else {
  413. if (leve == 'province') {
  414. this.addrProvinceList = []
  415. } else if (leve == 'city') {
  416. this.addrCityList = []
  417. } else if (leve == 'district') {
  418. this.addrDistrictList = []
  419. }
  420. }
  421. })
  422. },
  423. pageInit () {
  424. const _this = this
  425. this.$nextTick(() => { // 页面渲染完成后的回调
  426. _this.setTableH()
  427. })
  428. this.getArea('province')
  429. },
  430. setTableH () {
  431. const tableSearchH = this.$refs.tableSearch.offsetHeight
  432. this.tableHeight = window.innerHeight - tableSearchH - 310
  433. }
  434. },
  435. watch: {
  436. advanced (newValue, oldValue) {
  437. const _this = this
  438. setTimeout(() => {
  439. _this.setTableH()
  440. }, 400)
  441. }
  442. },
  443. mounted () {
  444. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  445. this.pageInit()
  446. this.resetSearchForm()
  447. }
  448. },
  449. activated () {
  450. // 如果是新页签打开,则重置当前页面
  451. if (this.$store.state.app.isNewTab) {
  452. this.pageInit()
  453. this.resetSearchForm()
  454. }
  455. },
  456. beforeRouteEnter (to, from, next) {
  457. next(vm => {})
  458. }
  459. }
  460. </script>
  461. <style lang="less">
  462. .salesManagementList-wrap{
  463. .sTable{
  464. margin-top: 10px;
  465. .badge-con-t{
  466. .ant-badge-count{
  467. transform: scale(0.8);
  468. font-size: 13px;
  469. }
  470. }
  471. }
  472. }
  473. </style>