list.vue 22 KB

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