list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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+87+'px' }"
  100. size="small"
  101. :rowKey="(record) => record.id"
  102. :columns="columns"
  103. :data="loadData"
  104. :scroll="{ x: 1400, y:tableHeight }"
  105. bordered>
  106. <!-- 销售单号 -->
  107. <template slot="salesBillNo" slot-scope="text, record">
  108. <span style="color: #ed1c24;cursor: pointer;" v-if="$hasPermissions('B_salesDetail')" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  109. <span v-else>{{ record.salesBillNo }}</span>
  110. </template>
  111. <!-- 急件 -->
  112. <template slot="oosFlag" slot-scope="text, record">
  113. <a-tag :color="record.oosFlag==1?'red':'#ccc'" >{{ record.oosFlagDictValue }}</a-tag>
  114. </template>
  115. <!-- 操作 -->
  116. <template slot="action" slot-scope="text, record">
  117. <a-button
  118. size="small"
  119. type="link"
  120. class="button-warning"
  121. v-if="record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')"
  122. @click="handleEexamine(record)"
  123. >审核</a-button>
  124. <a-button
  125. size="small"
  126. type="link"
  127. v-if="record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')"
  128. class="button-primary"
  129. @click="handleSend(record)"
  130. >出库</a-button>
  131. <a-button
  132. size="small"
  133. type="link"
  134. class="button-info"
  135. v-if="((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'AUDIT_REJECT')) && $hasPermissions('B_salesEdit')"
  136. @click="handleEdit(record)"
  137. >
  138. 编辑
  139. </a-button>
  140. <a-button
  141. size="small"
  142. type="link"
  143. class="button-error"
  144. v-if="((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel')"
  145. @click="handleDel(record)"
  146. >
  147. 删除
  148. </a-button>
  149. <a-button
  150. size="small"
  151. type="link"
  152. class="button-info"
  153. v-if="(record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesEdit')"
  154. @click="handleEdit(record)"
  155. >
  156. 改单
  157. </a-button>
  158. <a-button
  159. size="small"
  160. type="link"
  161. class="button-error"
  162. v-if="(record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel')"
  163. @click="handleDel(record, 'cancel')"
  164. >
  165. 取消
  166. </a-button>
  167. <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>
  168. </template>
  169. </s-table>
  170. </a-spin>
  171. <!-- 选择客户弹框 -->
  172. <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  173. <!-- 审核 -->
  174. <auditModal :openModal="visibleAudit" :spinning="spinningAudit" @close="visibleAudit=false" @ok="auditOrder('WAIT_OUT_WAREHOUSE')" @fail="auditOrder('AUDIT_REJECT')" />
  175. </a-card>
  176. </template>
  177. <script>
  178. import moment from 'moment'
  179. import { STable, VSelect } from '@/components'
  180. import chooseCustomModal from './chooseCustomModal.vue'
  181. import auditModal from '@/views/common/auditModal.vue'
  182. import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount, salesExport } from '@/api/sales'
  183. import { settleStyleQueryAll } from '@/api/settleStyle'
  184. import rangeDate from '@/views/common/rangeDate.vue'
  185. import custList from '@/views/common/custList.vue'
  186. export default {
  187. name: 'TableList',
  188. components: { STable, VSelect, chooseCustomModal, rangeDate, auditModal, custList },
  189. data () {
  190. return {
  191. spinning: false,
  192. tableHeight: 0,
  193. advanced: true, // 高级搜索 展开/关闭
  194. disabled: false, // 查询、重置按钮是否可操作
  195. exportLoading: false, // 导出loading
  196. openModal: false, // 选择客户弹框是否显示
  197. settleStyleList: [], // 收款方式
  198. // 查询参数
  199. queryParam: {
  200. beginDate: '',
  201. endDate: '',
  202. buyerSn: undefined, // 客户名称
  203. salesBillNo: '', // 销售单号
  204. purchaseBillNo: '', // 采购单号
  205. payType: undefined, // 支付方式
  206. settleStyleSn: undefined, // 收款方式
  207. billStatus: undefined, // 业务状态
  208. financialStatus: undefined // 财务状态
  209. },
  210. totalData: {
  211. totalAmount: 0,
  212. totalCategory: 0,
  213. totalQty: 0,
  214. totalRecord: 0
  215. },
  216. // 表头
  217. columns: [
  218. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  219. { title: '创建时间', dataIndex: 'createDate', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  220. { title: '来源', dataIndex: 'salesBillSourceDictValue', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
  221. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: 120, align: 'center' },
  222. { title: '采购单号', dataIndex: 'purchaseBillNo', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  223. { title: '客户名称', dataIndex: 'buyerName', align: 'center', customRender: function (text) { return text || '--' } },
  224. { title: '总款数', dataIndex: 'totalCategory', width: 60, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  225. { title: '总数量', dataIndex: 'totalQty', width: 60, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  226. { title: '总售价', dataIndex: 'totalAmount', width: 60, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  227. { title: '收款方式', dataIndex: 'settleStyleEntity.name', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
  228. { title: '审核时间', dataIndex: 'auditDate', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  229. { title: '急件', dataIndex: 'oosFlag', scopedSlots: { customRender: 'oosFlag' }, width: 60, align: 'center' },
  230. { title: '业务状态', dataIndex: 'billStatusDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  231. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  232. { title: '操作', scopedSlots: { customRender: 'action' }, width: 140, align: 'center', fixed: 'right' }
  233. ],
  234. // 加载数据方法 必须为 Promise 对象
  235. loadData: parameter => {
  236. this.disabled = true
  237. this.spinning = true
  238. // 查询总计
  239. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  240. this.totalData = Object.assign(this.totalData, res.data || {})
  241. })
  242. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  243. const data = res.data
  244. const no = (data.pageNo - 1) * data.pageSize
  245. for (var i = 0; i < data.list.length; i++) {
  246. data.list[i].no = no + i + 1
  247. }
  248. this.disabled = false
  249. this.spinning = false
  250. return data
  251. })
  252. },
  253. visibleAudit: false,
  254. auditInfo: null,
  255. spinningAudit: false
  256. }
  257. },
  258. methods: {
  259. // 时间 change
  260. dateChange (date) {
  261. this.queryParam.beginDate = date[0]
  262. this.queryParam.endDate = date[1]
  263. },
  264. // 新增
  265. handleAdd () {
  266. this.openModal = true
  267. },
  268. // 选择客户成功
  269. chooseCustomOk (data) {
  270. this.$router.push({ name: 'salesAdd', params: { id: data.id, sn: data.salesBillSn, priceType: data.priceType } })
  271. },
  272. // 审核
  273. handleEexamine (row) {
  274. this.auditInfo = row
  275. this.visibleAudit = true
  276. },
  277. auditOrder (billStatus) {
  278. this.spinningAudit = true
  279. salesWriteAudit({
  280. id: this.auditInfo.id,
  281. billStatus: billStatus
  282. }).then(res => {
  283. if (res.status == 200) {
  284. this.visibleAudit = false
  285. this.$message.success(res.message)
  286. this.$refs.table.refresh()
  287. this.spinningAudit = false
  288. } else {
  289. this.visibleAudit = false
  290. this.spinningAudit = false
  291. }
  292. })
  293. },
  294. // 出库
  295. handleSend (row) {
  296. const _this = this
  297. this.$confirm({
  298. title: '提示',
  299. content: '确认要出库吗?',
  300. centered: true,
  301. closable: true,
  302. onOk () {
  303. _this.spinning = true
  304. salesWriteStockOut({
  305. salesBillSn: row.salesBillSn
  306. }).then(res => {
  307. if (res.status == 200) {
  308. _this.$message.success(res.message)
  309. _this.$refs.table.refresh()
  310. _this.spinning = false
  311. } else {
  312. _this.spinning = false
  313. }
  314. })
  315. }
  316. })
  317. },
  318. // 详情
  319. handleDetail (row) {
  320. this.$router.push({ name: 'salesDetail', params: { sn: row.salesBillSn } })
  321. },
  322. // 编辑
  323. handleEdit (row) {
  324. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  325. },
  326. // 删除
  327. handleDel (row, type) {
  328. const _this = this
  329. let content = '确认要删除吗?'
  330. if (type == 'cancel') {
  331. content = '确认要取消吗?'
  332. }
  333. this.$confirm({
  334. title: '提示',
  335. content: content,
  336. centered: true,
  337. closable: true,
  338. onOk () {
  339. _this.spinning = true
  340. salesDel({ id: row.id }).then(res => {
  341. if (res.status == 200) {
  342. _this.$message.success(res.message)
  343. _this.$refs.table.refresh()
  344. _this.spinning = false
  345. } else {
  346. _this.spinning = false
  347. }
  348. })
  349. }
  350. })
  351. },
  352. // 客户 change
  353. custChange (obj) {
  354. this.queryParam.buyerSn = obj.key || undefined
  355. },
  356. // 重置
  357. resetSearchForm () {
  358. this.$refs.rangeDate.resetDate()
  359. this.queryParam.beginDate = ''
  360. this.queryParam.endDate = ''
  361. this.queryParam.buyerSn = undefined
  362. this.queryParam.salesBillNo = ''
  363. this.queryParam.purchaseBillNo = ''
  364. this.queryParam.payType = undefined
  365. this.queryParam.settleStyleSn = undefined
  366. this.queryParam.billStatus = undefined
  367. this.queryParam.financialStatus = undefined
  368. this.$refs.custList.resetForm()
  369. this.$refs.table.refresh(true)
  370. },
  371. // 导出
  372. handleExport () {
  373. const _this = this
  374. const params = this.queryParam
  375. this.exportLoading = true
  376. _this.spinning = true
  377. salesExport(params).then(res => {
  378. this.exportLoading = false
  379. _this.spinning = false
  380. if (res.type == 'application/json') {
  381. var reader = new FileReader()
  382. reader.addEventListener('loadend', function () {
  383. const obj = JSON.parse(reader.result)
  384. _this.$notification.error({
  385. message: '提示',
  386. description: obj.message
  387. })
  388. })
  389. reader.readAsText(res)
  390. } else {
  391. this.download(res)
  392. }
  393. })
  394. },
  395. download (data) {
  396. if (!data) { return }
  397. const url = window.URL.createObjectURL(new Blob([data]))
  398. const link = document.createElement('a')
  399. link.style.display = 'none'
  400. link.href = url
  401. const a = moment().format('YYYYMMDDHHmmss')
  402. const fname = '销售列表' + a
  403. link.setAttribute('download', fname + '.xlsx')
  404. document.body.appendChild(link)
  405. link.click()
  406. },
  407. // 获取收款方式
  408. getSettleStyle () {
  409. settleStyleQueryAll().then(res => {
  410. if (res.status == 200) {
  411. this.settleStyleList = res.data
  412. }
  413. })
  414. },
  415. setTableH () {
  416. const tableSearchH = this.$refs.tableSearch.offsetHeight
  417. this.tableHeight = window.innerHeight - tableSearchH - 275
  418. }
  419. },
  420. mounted () {
  421. const _this = this
  422. this.$nextTick(() => { // 页面渲染完成后的回调
  423. _this.setTableH()
  424. })
  425. },
  426. watch: {
  427. advanced (newValue, oldValue) {
  428. const _this = this
  429. setTimeout(() => {
  430. _this.setTableH()
  431. }, 400)
  432. }
  433. },
  434. beforeRouteEnter (to, from, next) {
  435. next(vm => {
  436. vm.getSettleStyle()
  437. })
  438. }
  439. }
  440. </script>
  441. <style lang="less">
  442. .ssalesManagementList-wrap{
  443. .sTable{
  444. margin-top: 15px;
  445. }
  446. }
  447. </style>