list.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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" @keyup.enter.native="$refs.table.refresh(true)">
  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. <custList ref="custList" @change="custChange" v-model="queryParam.buyerSn"></custList>
  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. code="SETTLE_STYLE"
  33. id="salesManagementList-settleStyleSn"
  34. v-model="queryParam.settleStyleSn"
  35. allowClear
  36. placeholder="请选择收款方式"
  37. ></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. </template>
  63. <a-col :md="6" :sm="24">
  64. <span class="table-page-search-submitButtons">
  65. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  66. <a-button style="margin-left: 5px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  67. <a-button
  68. type="primary"
  69. v-if="$hasPermissions('B_salesExport')"
  70. class="button-warning"
  71. @click="handleExport"
  72. :disabled="disabled"
  73. :loading="exportLoading"
  74. id="salesManagementList-export">导出</a-button>
  75. <a @click="advanced=!advanced" style="margin-left: 5px">
  76. {{ advanced ? '收起' : '展开' }}
  77. <a-icon :type="advanced ? 'up' : 'down'"/>
  78. </a>
  79. </span>
  80. </a-col>
  81. </a-row>
  82. </a-form>
  83. </div>
  84. <!-- 操作按钮 -->
  85. <div class="table-operator">
  86. <a-button type="primary" class="button-error" v-if="$hasPermissions('B_salesNews')" @click="handleAdd">新增(零售)</a-button>
  87. </div>
  88. <!-- alert -->
  89. <a-alert type="info" style="margin-bottom:10px">
  90. <div slot="message">
  91. 总售价:<strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? totalData.totalAmount : '--' }}</strong>元;
  92. 总单数:<strong>{{ totalData&&(totalData.totalRecord || totalData.totalRecord==0) ? totalData.totalRecord : '--' }}</strong>;
  93. 总款数:<strong>{{ totalData&&(totalData.totalCategory || totalData.totalCategory==0) ? totalData.totalCategory : '--' }}</strong>;
  94. 总数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  95. </div>
  96. </a-alert>
  97. <!-- 列表 -->
  98. <s-table
  99. class="sTable fixPagination"
  100. ref="table"
  101. :style="{ height: tableHeight+77+'px' }"
  102. size="small"
  103. :rowKey="(record) => record.id"
  104. :columns="columns"
  105. :data="loadData"
  106. :scroll="{ y:tableHeight }"
  107. :defaultLoadData="false"
  108. bordered>
  109. <!-- 销售单号 -->
  110. <template slot="salesBillNo" slot-scope="text, record">
  111. <span style="color: #ed1c24;cursor: pointer;" v-if="$hasPermissions('B_salesDetail')" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  112. <span v-else>{{ record.salesBillNo }}</span>
  113. <a-badge count="改" :offset="[10,0]" v-if="record.billStatus=='SUPERIOR_CHANGE'"></a-badge>
  114. </template>
  115. <!-- 审核 -->
  116. <template slot="audit" slot-scope="text, record">
  117. <stateIcon :title="record.billStatusDictValue" v-if="record.billStatus!='AUDIT_REJECT'" :state="record.billStatus == 'WAIT_OUT_WAREHOUSE'||record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  118. <stateIcon :title="record.billStatusDictValue" v-else :state="0"></stateIcon>
  119. </template>
  120. <!-- 急件 -->
  121. <template slot="oosFlag" slot-scope="text, record">
  122. <stateIcon :state="record.oosFlag==1?'1':'2'"></stateIcon>
  123. </template>
  124. <!-- 出库 -->
  125. <template slot="waitOut" slot-scope="text, record">
  126. <stateIcon :state="record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  127. </template>
  128. <!-- 收款 -->
  129. <template slot="financial" slot-scope="text, record">
  130. <stateIcon :title="record.financialStatusDictValue" :state="record.financialStatus == 'FINISH'?'1':'2'"></stateIcon>
  131. </template>
  132. <!-- 操作 -->
  133. <template slot="action" slot-scope="text, record">
  134. <a-button
  135. size="small"
  136. type="link"
  137. class="button-primary"
  138. v-if="record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')"
  139. @click="handleEexamine(record)"
  140. >审核</a-button>
  141. <a-button
  142. size="small"
  143. type="link"
  144. v-if="record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')"
  145. class="button-primary"
  146. @click="handleSend(record)"
  147. >出库</a-button>
  148. <a-button
  149. size="small"
  150. type="link"
  151. class="button-primary"
  152. v-if="((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES' || record.salesBillSource == 'TEMPORARY_DISPATCHING') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'AUDIT_REJECT')) && $hasPermissions('B_salesEdit')"
  153. @click="handleEdit(record)"
  154. >
  155. 编辑
  156. </a-button>
  157. <a-button
  158. size="small"
  159. type="link"
  160. class="button-error"
  161. v-if="((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES' || record.salesBillSource == 'TEMPORARY_DISPATCHING') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel')"
  162. @click="handleDel(record)"
  163. >
  164. 删除
  165. </a-button>
  166. <a-button
  167. size="small"
  168. type="link"
  169. class="button-primary"
  170. v-if="(record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesEdit')"
  171. @click="handleEdit(record)"
  172. >
  173. 改单
  174. </a-button>
  175. <a-button
  176. size="small"
  177. type="link"
  178. class="button-error"
  179. v-if="(record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel')"
  180. @click="handleDel(record, 'cancel')"
  181. >
  182. 取消
  183. </a-button>
  184. <span v-if="!(record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')) && !(record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')) && !(((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES' || record.salesBillSource == 'TEMPORARY_DISPATCHING') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'AUDIT_REJECT')) && $hasPermissions('B_salesEdit')) && !(((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES' || record.salesBillSource == 'TEMPORARY_DISPATCHING') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel')) && !((record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesEdit')) && !((record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel'))">--</span>
  185. </template>
  186. </s-table>
  187. </a-spin>
  188. <!-- 选择客户弹框 -->
  189. <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  190. <!-- 审核 -->
  191. <auditModal :openModal="visibleAudit" :spinning="spinningAudit" @close="visibleAudit=false" @ok="auditOrder('WAIT_OUT_WAREHOUSE')" @fail="auditOrder('AUDIT_REJECT')" />
  192. </a-card>
  193. </template>
  194. <script>
  195. import { commonMixin } from '@/utils/mixin'
  196. import getDate from '@/libs/getDate.js'
  197. import { STable, VSelect } from '@/components'
  198. import chooseCustomModal from './chooseCustomModal.vue'
  199. import auditModal from '@/views/common/auditModal.vue'
  200. import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount, salesExport } from '@/api/sales'
  201. import rangeDate from '@/views/common/rangeDate.vue'
  202. import custList from '@/views/common/custList.vue'
  203. import { downloadExcel } from '@/libs/JGPrint.js'
  204. import stateIcon from '@/views/common/stateIcon'
  205. export default {
  206. name: 'SalesList',
  207. components: { STable, VSelect, chooseCustomModal, rangeDate, auditModal, custList, stateIcon },
  208. mixins: [commonMixin],
  209. data () {
  210. return {
  211. spinning: false,
  212. tableHeight: 0,
  213. advanced: true, // 高级搜索 展开/关闭
  214. disabled: false, // 查询、重置按钮是否可操作
  215. exportLoading: false, // 导出loading
  216. openModal: false, // 选择客户弹框是否显示
  217. time: [
  218. getDate.getCurrMonthDays().starttime,
  219. getDate.getCurrMonthDays().endtime
  220. ],
  221. // 查询参数
  222. queryParam: {
  223. beginDate: getDate.getCurrMonthDays().starttime,
  224. endDate: getDate.getCurrMonthDays().endtime,
  225. buyerSn: undefined, // 客户名称
  226. salesBillNo: '', // 销售单号
  227. purchaseBillNo: '', // 采购单号
  228. payType: undefined, // 支付方式
  229. settleStyleSn: undefined, // 收款方式
  230. billStatus: undefined, // 业务状态
  231. financialStatus: undefined // 财务状态
  232. },
  233. totalData: {
  234. totalAmount: 0,
  235. totalCategory: 0,
  236. totalQty: 0,
  237. totalRecord: 0
  238. },
  239. // 表头
  240. columns: [
  241. { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
  242. { title: '来源', dataIndex: 'salesBillSourceDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  243. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: '9%', align: 'center' },
  244. { title: '客户名称', dataIndex: 'buyerName', align: 'center', width: '15%', customRender: function (text) { return text || '--' } },
  245. { title: '总款数', dataIndex: 'totalCategory', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  246. { title: '总数量', dataIndex: 'totalQty', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  247. { title: '总售价', dataIndex: 'totalAmount', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  248. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  249. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  250. { title: '审核时间', dataIndex: 'auditDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  251. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  252. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '2%', align: 'center' },
  253. { title: '急件', scopedSlots: { customRender: 'oosFlag' }, width: '2%', align: 'center' },
  254. { title: '出库', scopedSlots: { customRender: 'waitOut' }, width: '2%', align: 'center' },
  255. { title: '收款', scopedSlots: { customRender: 'financial' }, width: '2%', align: 'center' },
  256. // { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  257. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  258. ],
  259. // 加载数据方法 必须为 Promise 对象
  260. loadData: parameter => {
  261. this.disabled = true
  262. this.spinning = true
  263. // 查询总计
  264. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  265. console.log(res, 'res')
  266. this.totalData = Object.assign(this.totalData, res.data || {})
  267. })
  268. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  269. let data
  270. if (res.status == 200) {
  271. data = res.data
  272. const no = (data.pageNo - 1) * data.pageSize
  273. for (var i = 0; i < data.list.length; i++) {
  274. data.list[i].no = no + i + 1
  275. }
  276. this.disabled = false
  277. }
  278. console.log(res, 'res')
  279. this.spinning = false
  280. return data
  281. })
  282. },
  283. visibleAudit: false,
  284. auditInfo: null,
  285. spinningAudit: false
  286. }
  287. },
  288. methods: {
  289. // 时间 change
  290. dateChange (date) {
  291. this.queryParam.beginDate = date[0]
  292. this.queryParam.endDate = date[1]
  293. },
  294. // 新增
  295. handleAdd () {
  296. this.openModal = true
  297. },
  298. // 审核
  299. handleEexamine (row) {
  300. this.auditInfo = row
  301. this.visibleAudit = true
  302. },
  303. auditOrder (billStatus) {
  304. this.spinningAudit = true
  305. salesWriteAudit({
  306. id: this.auditInfo.id,
  307. billStatus: billStatus
  308. }).then(res => {
  309. if (res.status == 200) {
  310. this.visibleAudit = false
  311. this.$message.success(res.message)
  312. this.$refs.table.refresh()
  313. this.spinningAudit = false
  314. } else {
  315. this.visibleAudit = false
  316. this.spinningAudit = false
  317. }
  318. })
  319. },
  320. // 出库
  321. handleSend (row) {
  322. const _this = this
  323. this.$confirm({
  324. title: '提示',
  325. content: '确认要出库吗?',
  326. centered: true,
  327. closable: true,
  328. onOk () {
  329. _this.spinning = true
  330. salesWriteStockOut({
  331. salesBillSn: row.salesBillSn
  332. }).then(res => {
  333. if (res.status == 200) {
  334. _this.$message.success(res.message)
  335. _this.$refs.table.refresh()
  336. _this.spinning = false
  337. } else {
  338. _this.spinning = false
  339. }
  340. })
  341. }
  342. })
  343. },
  344. // 详情
  345. handleDetail (row) {
  346. this.$router.push({ name: 'salesDetail', params: { sn: row.salesBillSn } })
  347. },
  348. // 编辑
  349. handleEdit (row) {
  350. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  351. },
  352. // 选择客户成功
  353. chooseCustomOk (data) {
  354. this.resetData()
  355. this.setIsHomeNav(this.$route.name, null)
  356. this.$router.push({ name: 'salesAdd', params: { id: data.id, sn: data.salesBillSn, priceType: data.priceType } })
  357. },
  358. // 删除
  359. handleDel (row, type) {
  360. const _this = this
  361. let content = '确认要删除吗?'
  362. if (type == 'cancel') {
  363. content = '确认要取消吗?'
  364. }
  365. this.$confirm({
  366. title: '提示',
  367. content: content,
  368. centered: true,
  369. closable: true,
  370. onOk () {
  371. _this.spinning = true
  372. salesDel({ id: row.id }).then(res => {
  373. if (res.status == 200) {
  374. _this.$message.success(res.message)
  375. _this.$refs.table.refresh()
  376. _this.spinning = false
  377. } else {
  378. _this.spinning = false
  379. }
  380. })
  381. }
  382. })
  383. },
  384. // 客户 change
  385. custChange (obj) {
  386. this.queryParam.buyerSn = obj.key || undefined
  387. },
  388. // 重置
  389. resetSearchForm () {
  390. this.resetData()
  391. this.$refs.table.refresh(true)
  392. },
  393. // 重置数据
  394. resetData (falg) {
  395. this.$refs.rangeDate.resetDate(falg ? '' : this.time)
  396. this.queryParam.beginDate = falg ? '' : getDate.getCurrMonthDays().starttime
  397. this.queryParam.endDate = falg ? '' : getDate.getCurrMonthDays().endtime
  398. this.queryParam.buyerSn = undefined
  399. this.queryParam.salesBillNo = ''
  400. this.queryParam.purchaseBillNo = ''
  401. this.queryParam.payType = undefined
  402. this.queryParam.settleStyleSn = undefined
  403. this.queryParam.billStatus = undefined
  404. this.queryParam.financialStatus = undefined
  405. this.$refs.custList.resetForm()
  406. },
  407. // 导出
  408. handleExport () {
  409. const _this = this
  410. const params = this.queryParam
  411. this.exportLoading = true
  412. _this.spinning = true
  413. salesExport(params).then(res => {
  414. this.exportLoading = false
  415. _this.spinning = false
  416. if (res.type == 'application/json') {
  417. var reader = new FileReader()
  418. reader.addEventListener('loadend', function () {
  419. const obj = JSON.parse(reader.result)
  420. _this.$notification.error({
  421. message: '提示',
  422. description: obj.message
  423. })
  424. })
  425. reader.readAsText(res)
  426. } else {
  427. downloadExcel(res, '销售列表')
  428. }
  429. })
  430. },
  431. setTableH () {
  432. const tableSearchH = this.$refs.tableSearch.offsetHeight
  433. this.tableHeight = window.innerHeight - tableSearchH - 265
  434. },
  435. pageInit () {
  436. const _this = this
  437. this.$nextTick(() => { // 页面渲染完成后的回调
  438. _this.setTableH()
  439. })
  440. // 是否打开的页签
  441. const a = this.$store.state.app.isNewTab
  442. // 是否要刷新列表
  443. const b = this.$store.state.app.updateList
  444. // 是否从首页点击进入
  445. const isHomeNav = this.getIsHomeNav()[this.$route.name]
  446. console.log(a, b, this.getIsHomeNav(), isHomeNav, this.$route.name)
  447. // 从首页进入,判断式新建还式待办查询
  448. if (isHomeNav) {
  449. // 新增
  450. if (isHomeNav.type == 'new') {
  451. this.resetSearchForm()
  452. this.openModal = true
  453. this.setIsHomeNav(this.$route.name, null)
  454. }
  455. // 待办
  456. if (isHomeNav.type == 'todo') {
  457. this.resetData(true)
  458. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  459. this.$refs.table.refresh(true)
  460. }
  461. } else {
  462. // 如果是新页签打开,则重置当前页面
  463. if (a && !b) {
  464. this.resetSearchForm()
  465. }
  466. }
  467. // 仅刷新列表,不重置页面
  468. if (b) {
  469. this.$refs.table.refresh()
  470. }
  471. }
  472. },
  473. watch: {
  474. advanced (newValue, oldValue) {
  475. const _this = this
  476. this.$nextTick(() => { // 页面渲染完成后的回调
  477. _this.setTableH()
  478. })
  479. },
  480. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  481. this.setTableH()
  482. }
  483. },
  484. activated () {
  485. this.pageInit()
  486. },
  487. beforeRouteEnter (to, from, next) {
  488. next(vm => {
  489. })
  490. }
  491. }
  492. </script>