list.vue 18 KB

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