list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <a-card size="small" :bordered="false" class="salesManagementList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div 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. <a-select
  16. id="salesManagementList-buyerName"
  17. placeholder="请选择客户"
  18. allowClear
  19. v-model="queryParam.buyerName"
  20. :showSearch="true"
  21. option-filter-prop="children"
  22. :filter-option="filterOption">
  23. <a-select-option v-for="item in custAllList" :key="item.customerSn" :value="item.customerName">{{ item.customerName }}</a-select-option>
  24. </a-select>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-item label="销售单号">
  29. <a-input id="salesManagementList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  30. </a-form-item>
  31. </a-col>
  32. <template v-if="advanced">
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="采购单号">
  35. <a-input id="salesManagementList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-item label="收款方式">
  40. <a-select placeholder="请选择收款方式" v-model="queryParam.settleStyleSn">
  41. <a-select-option v-for="item in settleStyleList" :key="item.settleStyleSn" :value="item.settleStyleSn">
  42. {{ item.name }}
  43. </a-select-option>
  44. </a-select>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :md="6" :sm="24">
  48. <a-form-item label="业务状态">
  49. <v-select
  50. v-model="queryParam.billStatus"
  51. ref="billStatus"
  52. id="salesManagementList-billStatus"
  53. code="SALES_BILL_STATUS"
  54. placeholder="请选择业务状态"
  55. allowClear></v-select>
  56. </a-form-item>
  57. </a-col>
  58. <a-col :md="6" :sm="24">
  59. <a-form-item label="财务状态">
  60. <v-select
  61. v-model="queryParam.financialStatus"
  62. ref="financialStatus"
  63. id="salesManagementList-financialStatus"
  64. code="FINANCIAL_RECEIVE_STATUS"
  65. placeholder="请选择财务状态"
  66. allowClear></v-select>
  67. </a-form-item>
  68. </a-col>
  69. </template>
  70. <a-col :md="6" :sm="24">
  71. <span class="table-page-search-submitButtons">
  72. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  73. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  74. <a @click="advanced=!advanced" style="margin-left: 8px">
  75. {{ advanced ? '收起' : '展开' }}
  76. <a-icon :type="advanced ? 'up' : 'down'"/>
  77. </a>
  78. </span>
  79. </a-col>
  80. </a-row>
  81. </a-form>
  82. </div>
  83. <!-- 操作按钮 -->
  84. <div class="table-operator">
  85. <a-button type="primary" class="button-error" v-if="$hasPermissions('B_salesNews')" @click="handleAdd">新增(零售)</a-button>
  86. </div>
  87. <!-- alert -->
  88. <a-alert type="info" showIcon style="margin-bottom:15px">
  89. <div slot="message">
  90. 总售价:<strong>{{ totalData.totalAmount }}</strong>元;
  91. 总单数:<strong>{{ totalData.totalRecord }}</strong>;
  92. 总款数:<strong>{{ totalData.totalCategory }}</strong>;
  93. 总数量:<strong>{{ totalData.totalQty }}</strong>;
  94. </div>
  95. </a-alert>
  96. <!-- 列表 -->
  97. <s-table
  98. class="sTable"
  99. ref="table"
  100. size="default"
  101. :rowKey="(record) => record.id"
  102. :columns="columns"
  103. :data="loadData"
  104. :scroll="{ x: 2050, 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="financialStatus" slot-scope="text, record">
  117. <a-badge :color="text=='FINISH'?'#87d068':'gold'" :text="record.financialStatusDictValue" />
  118. </template>
  119. <!-- 操作 -->
  120. <template slot="action" slot-scope="text, record">
  121. <a-button
  122. size="small"
  123. type="link"
  124. class="button-warning"
  125. v-if="record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')"
  126. @click="handleEexamine(record)"
  127. >审核</a-button>
  128. <a-button
  129. size="small"
  130. type="link"
  131. v-if="record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')"
  132. class="button-primary"
  133. @click="handleSend(record)"
  134. >出库</a-button>
  135. <a-button
  136. size="small"
  137. type="link"
  138. class="button-info"
  139. v-if="((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'AUDIT_REJECT')) && $hasPermissions('B_salesEdit')"
  140. @click="handleEdit(record)"
  141. >
  142. 编辑
  143. </a-button>
  144. <a-button
  145. size="small"
  146. type="link"
  147. class="button-error"
  148. v-if="((record.salesBillSource == 'SATELLITE' || record.salesBillSource == 'SALES') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel')"
  149. @click="handleDel(record)"
  150. >
  151. 删除
  152. </a-button>
  153. <a-button
  154. size="small"
  155. type="link"
  156. class="button-info"
  157. v-if="(record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesEdit')"
  158. @click="handleEdit(record)"
  159. >
  160. 改单
  161. </a-button>
  162. <a-button
  163. size="small"
  164. type="link"
  165. class="button-error"
  166. v-if="(record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel')"
  167. @click="handleDel(record, 'cancel')"
  168. >
  169. 取消
  170. </a-button>
  171. <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>
  172. </template>
  173. </s-table>
  174. </a-spin>
  175. <!-- 选择客户弹框 -->
  176. <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  177. <!-- 审核 -->
  178. <auditModal :openModal="visibleAudit" @close="visibleAudit=false" @ok="auditOrder('WAIT_OUT_WAREHOUSE')" @fail="auditOrder('AUDIT_REJECT')" />
  179. </a-card>
  180. </template>
  181. <script>
  182. import { STable, VSelect } from '@/components'
  183. import chooseCustomModal from './chooseCustomModal.vue'
  184. import auditModal from '@/views/common/auditModal.vue'
  185. import { custAllList } from '@/api/customer'
  186. import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount } from '@/api/sales'
  187. import { settleStyleQueryAll } from '@/api/settleStyle'
  188. import rangeDate from '@/views/common/rangeDate.vue'
  189. export default {
  190. name: 'TableList',
  191. components: { STable, VSelect, chooseCustomModal, rangeDate, auditModal },
  192. data () {
  193. return {
  194. spinning: false,
  195. tableHeight: 0,
  196. advanced: false, // 高级搜索 展开/关闭
  197. disabled: false, // 查询、重置按钮是否可操作
  198. openModal: false, // 选择客户弹框是否显示
  199. custAllList: [], // 客户 下拉数据
  200. settleStyleList: [], // 收款方式
  201. // 查询参数
  202. queryParam: {
  203. beginDate: '',
  204. endDate: '',
  205. buyerName: undefined, // 客户名称
  206. salesBillNo: '', // 销售单号
  207. purchaseBillNo: '', // 采购单号
  208. payType: undefined, // 支付方式
  209. settleStyleSn: undefined, // 收款方式
  210. billStatus: undefined, // 业务状态
  211. financialStatus: undefined // 财务状态
  212. },
  213. totalData: {
  214. totalAmount: 0,
  215. totalCategory: 0,
  216. totalQty: 0,
  217. totalRecord: 0
  218. },
  219. // 表头
  220. columns: [
  221. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  222. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  223. { title: '来源', dataIndex: 'salesBillSourceDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  224. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: 210, align: 'center' },
  225. { title: '采购单号', dataIndex: 'purchaseBillNo', width: 210, align: 'center', customRender: function (text) { return text || '--' } },
  226. { title: '客户名称', dataIndex: 'buyerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  227. { title: '总款数', dataIndex: 'totalCategory', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  228. { title: '总数量', dataIndex: 'totalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  229. { title: '总售价', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  230. { title: '收款方式', dataIndex: 'settleStyleEntity.name', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  231. { title: '审核时间', dataIndex: 'auditDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  232. { title: '急件', dataIndex: 'oosFlag', scopedSlots: { customRender: 'oosFlag' }, width: 100, align: 'center' },
  233. { title: '业务状态', dataIndex: 'billStatusDictValue', width: 110, align: 'center', customRender: function (text) { return text || '--' } },
  234. { title: '财务状态', dataIndex: 'financialStatus', scopedSlots: { customRender: 'financialStatus' }, width: 110, align: 'center' },
  235. { title: '操作', scopedSlots: { customRender: 'action' }, width: 220, align: 'center', fixed: 'right' }
  236. ],
  237. // 加载数据方法 必须为 Promise 对象
  238. loadData: parameter => {
  239. this.disabled = true
  240. if (this.tableHeight == 0) {
  241. this.tableHeight = window.innerHeight - 440
  242. }
  243. // 查询总计
  244. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  245. this.totalData = Object.assign(this.totalData, res.data || {})
  246. })
  247. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  248. const data = res.data
  249. const no = (data.pageNo - 1) * data.pageSize
  250. for (var i = 0; i < data.list.length; i++) {
  251. data.list[i].no = no + i + 1
  252. }
  253. this.disabled = false
  254. return data
  255. })
  256. },
  257. visibleAudit: false,
  258. auditInfo: null
  259. }
  260. },
  261. methods: {
  262. // 时间 change
  263. dateChange (date) {
  264. this.queryParam.beginDate = date[0]
  265. this.queryParam.endDate = date[1]
  266. },
  267. // 新增
  268. handleAdd () {
  269. this.openModal = true
  270. },
  271. // 选择客户成功
  272. chooseCustomOk (data) {
  273. this.$router.push({ name: 'salesAdd', params: { id: data.id, sn: data.salesBillSn, priceType: data.priceType } })
  274. },
  275. // 审核
  276. handleEexamine (row) {
  277. this.auditInfo = row
  278. this.visibleAudit = true
  279. },
  280. auditOrder (billStatus) {
  281. this.spinning = true
  282. salesWriteAudit({
  283. id: this.auditInfo.id,
  284. billStatus: billStatus
  285. }).then(res => {
  286. if (res.status == 200) {
  287. this.visibleAudit = false
  288. this.$message.success(res.message)
  289. this.$refs.table.refresh()
  290. this.spinning = false
  291. } else {
  292. this.visibleAudit = false
  293. this.spinning = false
  294. }
  295. })
  296. },
  297. // 出库
  298. handleSend (row) {
  299. const _this = this
  300. this.$confirm({
  301. title: '提示',
  302. content: '确认要出库吗?',
  303. centered: true,
  304. closable: true,
  305. onOk () {
  306. _this.spinning = true
  307. salesWriteStockOut({
  308. salesBillSn: row.salesBillSn
  309. }).then(res => {
  310. if (res.status == 200) {
  311. _this.$message.success(res.message)
  312. _this.$refs.table.refresh()
  313. _this.spinning = false
  314. } else {
  315. _this.spinning = false
  316. }
  317. })
  318. }
  319. })
  320. },
  321. // 详情
  322. handleDetail (row) {
  323. this.$router.push({ name: 'salesDetail', params: { sn: row.salesBillSn } })
  324. },
  325. // 编辑
  326. handleEdit (row) {
  327. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  328. },
  329. // 删除
  330. handleDel (row, type) {
  331. const _this = this
  332. let content = '确认要删除吗?'
  333. if (type == 'cancel') {
  334. content = '确认要取消吗?'
  335. }
  336. this.$confirm({
  337. title: '提示',
  338. content: content,
  339. centered: true,
  340. closable: true,
  341. onOk () {
  342. _this.spinning = true
  343. salesDel({ id: row.id }).then(res => {
  344. if (res.status == 200) {
  345. _this.$message.success(res.message)
  346. _this.$refs.table.refresh()
  347. _this.spinning = false
  348. } else {
  349. _this.spinning = false
  350. }
  351. })
  352. }
  353. })
  354. },
  355. // 客户无分页列表数据
  356. getCustAllList () {
  357. const _this = this
  358. custAllList().then(res => {
  359. if (res.status == 200) {
  360. _this.custAllList = res.data || []
  361. } else {
  362. _this.custAllList = []
  363. }
  364. })
  365. },
  366. // 重置
  367. resetSearchForm () {
  368. this.$refs.rangeDate.resetDate()
  369. this.queryParam.beginDate = ''
  370. this.queryParam.endDate = ''
  371. this.queryParam.buyerName = undefined
  372. this.queryParam.salesBillNo = ''
  373. this.queryParam.purchaseBillNo = ''
  374. this.queryParam.payType = undefined
  375. this.queryParam.settleStyleSn = undefined
  376. this.queryParam.billStatus = undefined
  377. this.queryParam.financialStatus = undefined
  378. this.$refs.table.refresh(true)
  379. },
  380. filterOption (input, option) {
  381. return (
  382. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  383. )
  384. },
  385. // 获取收款方式
  386. getSettleStyle () {
  387. settleStyleQueryAll().then(res => {
  388. if (res.status == 200) {
  389. this.settleStyleList = res.data
  390. }
  391. })
  392. }
  393. },
  394. beforeRouteEnter (to, from, next) {
  395. next(vm => {
  396. vm.getCustAllList()
  397. vm.getSettleStyle()
  398. })
  399. }
  400. }
  401. </script>
  402. <style lang="less">
  403. .ssalesManagementList-wrap{
  404. .sTable{
  405. margin-top: 15px;
  406. }
  407. }
  408. </style>