list.vue 19 KB

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