list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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 moment from 'moment'
  181. import getDate from '@/libs/getDate.js'
  182. import { STable, VSelect } from '@/components'
  183. import chooseCustomModal from './chooseCustomModal.vue'
  184. import auditModal from '@/views/common/auditModal.vue'
  185. import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount, salesExport } from '@/api/sales'
  186. import { settleStyleQueryAll } from '@/api/settleStyle'
  187. import rangeDate from '@/views/common/rangeDate.vue'
  188. import custList from '@/views/common/custList.vue'
  189. import { downloadExcel } from '@/libs/JGPrint.js'
  190. export default {
  191. name: 'TableList',
  192. components: { STable, VSelect, chooseCustomModal, rangeDate, auditModal, custList },
  193. data () {
  194. return {
  195. spinning: false,
  196. tableHeight: 0,
  197. advanced: true, // 高级搜索 展开/关闭
  198. disabled: false, // 查询、重置按钮是否可操作
  199. exportLoading: false, // 导出loading
  200. openModal: false, // 选择客户弹框是否显示
  201. settleStyleList: [], // 收款方式
  202. time: [
  203. getDate.getCurrMonthDays().starttime,
  204. getDate.getCurrMonthDays().endtime
  205. ],
  206. // 查询参数
  207. queryParam: {
  208. beginDate: getDate.getCurrMonthDays().starttime,
  209. endDate: getDate.getCurrMonthDays().endtime,
  210. buyerSn: undefined, // 客户名称
  211. salesBillNo: '', // 销售单号
  212. purchaseBillNo: '', // 采购单号
  213. payType: undefined, // 支付方式
  214. settleStyleSn: undefined, // 收款方式
  215. billStatus: undefined, // 业务状态
  216. financialStatus: undefined // 财务状态
  217. },
  218. totalData: {
  219. totalAmount: 0,
  220. totalCategory: 0,
  221. totalQty: 0,
  222. totalRecord: 0
  223. },
  224. // 表头
  225. columns: [
  226. { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
  227. { title: '来源', dataIndex: 'salesBillSourceDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  228. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: '9%', align: 'center' },
  229. { title: '客户名称', dataIndex: 'buyerName', align: 'center', width: '15%', customRender: function (text) { return text || '--' } },
  230. { title: '总款数', dataIndex: 'totalCategory', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  231. { title: '总数量', dataIndex: 'totalQty', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  232. { title: '总售价', dataIndex: 'totalAmount', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  233. { title: '收款方式', dataIndex: 'settleStyleEntity.name', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  234. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  235. { title: '审核时间', dataIndex: 'auditDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  236. { title: '急件', dataIndex: 'oosFlag', scopedSlots: { customRender: 'oosFlag' }, width: '5%', align: 'center' },
  237. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  239. { title: '操作', scopedSlots: { customRender: 'action' }, width: '12%', align: 'center' }
  240. ],
  241. // 加载数据方法 必须为 Promise 对象
  242. loadData: parameter => {
  243. this.disabled = true
  244. this.spinning = true
  245. // 查询总计
  246. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  247. this.totalData = Object.assign(this.totalData, res.data || {})
  248. })
  249. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  250. const data = res.data
  251. const no = (data.pageNo - 1) * data.pageSize
  252. for (var i = 0; i < data.list.length; i++) {
  253. data.list[i].no = no + i + 1
  254. }
  255. this.disabled = false
  256. this.spinning = false
  257. return data
  258. })
  259. },
  260. visibleAudit: false,
  261. auditInfo: null,
  262. spinningAudit: false
  263. }
  264. },
  265. methods: {
  266. // 时间 change
  267. dateChange (date) {
  268. this.queryParam.beginDate = date[0]
  269. this.queryParam.endDate = date[1]
  270. },
  271. // 新增
  272. handleAdd () {
  273. this.openModal = true
  274. },
  275. // 选择客户成功
  276. chooseCustomOk (data) {
  277. this.$router.push({ name: 'salesAdd', params: { id: data.id, sn: data.salesBillSn, priceType: data.priceType } })
  278. },
  279. // 审核
  280. handleEexamine (row) {
  281. this.auditInfo = row
  282. this.visibleAudit = true
  283. },
  284. auditOrder (billStatus) {
  285. this.spinningAudit = true
  286. salesWriteAudit({
  287. id: this.auditInfo.id,
  288. billStatus: billStatus
  289. }).then(res => {
  290. if (res.status == 200) {
  291. this.visibleAudit = false
  292. this.$message.success(res.message)
  293. this.$refs.table.refresh()
  294. this.spinningAudit = false
  295. } else {
  296. this.visibleAudit = false
  297. this.spinningAudit = false
  298. }
  299. })
  300. },
  301. // 出库
  302. handleSend (row) {
  303. const _this = this
  304. this.$confirm({
  305. title: '提示',
  306. content: '确认要出库吗?',
  307. centered: true,
  308. closable: true,
  309. onOk () {
  310. _this.spinning = true
  311. salesWriteStockOut({
  312. salesBillSn: row.salesBillSn
  313. }).then(res => {
  314. if (res.status == 200) {
  315. _this.$message.success(res.message)
  316. _this.$refs.table.refresh()
  317. _this.spinning = false
  318. } else {
  319. _this.spinning = false
  320. }
  321. })
  322. }
  323. })
  324. },
  325. // 详情
  326. handleDetail (row) {
  327. this.$router.push({ name: 'salesDetail', params: { sn: row.salesBillSn } })
  328. },
  329. // 编辑
  330. handleEdit (row) {
  331. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  332. },
  333. // 删除
  334. handleDel (row, type) {
  335. const _this = this
  336. let content = '确认要删除吗?'
  337. if (type == 'cancel') {
  338. content = '确认要取消吗?'
  339. }
  340. this.$confirm({
  341. title: '提示',
  342. content: content,
  343. centered: true,
  344. closable: true,
  345. onOk () {
  346. _this.spinning = true
  347. salesDel({ id: row.id }).then(res => {
  348. if (res.status == 200) {
  349. _this.$message.success(res.message)
  350. _this.$refs.table.refresh()
  351. _this.spinning = false
  352. } else {
  353. _this.spinning = false
  354. }
  355. })
  356. }
  357. })
  358. },
  359. // 客户 change
  360. custChange (obj) {
  361. this.queryParam.buyerSn = obj.key || undefined
  362. },
  363. // 重置
  364. resetSearchForm () {
  365. this.$refs.rangeDate.resetDate(this.time)
  366. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  367. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  368. this.queryParam.buyerSn = undefined
  369. this.queryParam.salesBillNo = ''
  370. this.queryParam.purchaseBillNo = ''
  371. this.queryParam.payType = undefined
  372. this.queryParam.settleStyleSn = undefined
  373. this.queryParam.billStatus = undefined
  374. this.queryParam.financialStatus = undefined
  375. this.$refs.custList.resetForm()
  376. this.$refs.table.refresh(true)
  377. },
  378. // 导出
  379. handleExport () {
  380. const _this = this
  381. const params = this.queryParam
  382. this.exportLoading = true
  383. _this.spinning = true
  384. salesExport(params).then(res => {
  385. this.exportLoading = false
  386. _this.spinning = false
  387. if (res.type == 'application/json') {
  388. var reader = new FileReader()
  389. reader.addEventListener('loadend', function () {
  390. const obj = JSON.parse(reader.result)
  391. _this.$notification.error({
  392. message: '提示',
  393. description: obj.message
  394. })
  395. })
  396. reader.readAsText(res)
  397. } else {
  398. const fileName = '销售列表' + moment().format('YYYYMMDDHHmmss')
  399. downloadExcel(res, fileName)
  400. }
  401. })
  402. },
  403. // 获取收款方式
  404. getSettleStyle () {
  405. settleStyleQueryAll().then(res => {
  406. if (res.status == 200) {
  407. this.settleStyleList = res.data
  408. }
  409. })
  410. },
  411. setTableH () {
  412. const tableSearchH = this.$refs.tableSearch.offsetHeight
  413. this.tableHeight = window.innerHeight - tableSearchH - 265
  414. },
  415. pageInit () {
  416. const _this = this
  417. this.$nextTick(() => { // 页面渲染完成后的回调
  418. _this.setTableH()
  419. })
  420. _this.getSettleStyle()
  421. }
  422. },
  423. mounted () {
  424. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  425. this.pageInit()
  426. this.resetSearchForm()
  427. }
  428. },
  429. watch: {
  430. advanced (newValue, oldValue) {
  431. const _this = this
  432. setTimeout(() => {
  433. _this.setTableH()
  434. }, 400)
  435. },
  436. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  437. this.setTableH()
  438. }
  439. },
  440. activated () {
  441. // 如果是新页签打开,则重置当前页面
  442. if (this.$store.state.app.isNewTab) {
  443. this.pageInit()
  444. this.resetSearchForm()
  445. }
  446. // 仅刷新列表,不重置页面
  447. if (this.$store.state.app.updateList) {
  448. this.pageInit()
  449. this.$refs.table.refresh()
  450. }
  451. },
  452. beforeRouteEnter (to, from, next) {
  453. next(vm => {})
  454. }
  455. }
  456. </script>