list.vue 21 KB

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