list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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" :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. </template>
  63. <a-col :md="6" :sm="24">
  64. <span class="table-page-search-submitButtons">
  65. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  66. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  67. <a @click="advanced=!advanced" style="margin-left: 8px">
  68. {{ advanced ? '收起' : '展开' }}
  69. <a-icon :type="advanced ? 'up' : 'down'"/>
  70. </a>
  71. </span>
  72. </a-col>
  73. </a-row>
  74. </a-form>
  75. </div>
  76. <!-- 操作按钮 -->
  77. <!-- <div class="table-operator">
  78. <a-button type="primary" class="button-error" @click="handleAdd">新增</a-button>
  79. </div> -->
  80. <!-- alert -->
  81. <a-alert type="info" showIcon style="margin-bottom:15px">
  82. <div slot="message">
  83. <div>
  84. 总单数:<strong>{{ totalData.totalRecord }}</strong>;
  85. 总款数:<strong>{{ totalData.totalCategory }}</strong>;
  86. 总数量:<strong>{{ totalData.totalQty }}</strong>;
  87. 已下推数量:<strong>{{ totalData.totalPushedQty }}</strong>;
  88. 已发货数量:<strong>{{ totalData.totalDispatchQty }}</strong>;
  89. 已取消数量:<strong>{{ totalData.totalCancelQty }}</strong>;
  90. 待下推数量:<strong>{{ totalData.totalUnpushedQty }}</strong>;
  91. </div>
  92. <div>
  93. 总售价:<strong>{{ totalData.totalAmount }}</strong>元;
  94. 已下推金额::<strong>{{ totalData.totalPushedAmount }}</strong>元;
  95. 已取消金额::<strong>{{ totalData.totalCancelAmount }}</strong>元;
  96. 待下推金额::<strong>{{ totalData.totalUnpushedAmount }}</strong>元;
  97. 已发货金额::<strong>{{ totalData.totalDispatchAmount }}</strong>元;
  98. </div>
  99. </div>
  100. </a-alert>
  101. <!-- 列表 -->
  102. <s-table
  103. class="sTable"
  104. ref="table"
  105. size="default"
  106. :rowKey="(record) => record.id"
  107. :columns="columns"
  108. :data="loadData"
  109. :scroll="{ x: 2640, y:tableHeight }"
  110. bordered>
  111. <!-- 销售单号 -->
  112. <template slot="salesBillNo" slot-scope="text, record">
  113. <div v-if="$hasPermissions('B_salesDetail')">
  114. <a-badge :count="'改'+record.changeTimes" :offset="[0,-10]" v-if="record.changeTimes>0">
  115. <span style="color: #00aaff;cursor: pointer;" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  116. </a-badge>
  117. <span v-else style="color: #00aaff;cursor: pointer;" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  118. </div>
  119. <div v-else>{{ record.salesBillNo }}</div>
  120. </template>
  121. <!-- 总数量 -->
  122. <template slot="totalQty" slot-scope="text, record">
  123. {{ record.totalQty }}
  124. </template>
  125. <!-- 财务状态 -->
  126. <template slot="financialStatus" slot-scope="text, record">
  127. <a-badge :color="text=='FINISH'?'#87d068':'gold'" :text="record.financialStatusDictValue" />
  128. </template>
  129. <!-- 操作 -->
  130. <template slot="action" slot-scope="text, record">
  131. <a-button
  132. size="small"
  133. type="link"
  134. class="button-warning"
  135. v-if="record.billStatus == 'WAIT_AUDIT'&&$hasPermissions('B_salesAudit')"
  136. @click="handleEexamine(record)"
  137. >审核</a-button>
  138. <a-button
  139. size="small"
  140. type="link"
  141. class="button-warning"
  142. v-if="record.billStatus == 'OUTING_WAREHOUSE'&&record.totalUnpushedQty>0&&$hasPermissions('B_salesDispatch')"
  143. @click="handleDispatch(record)"
  144. >下推</a-button>
  145. <a-button
  146. size="small"
  147. type="link"
  148. class="button-info"
  149. v-if="record.salesBillSource != 'PURCHASE' && (record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'AUDIT_REJECT')&&$hasPermissions('B_salesEdit')"
  150. @click="handleEdit(record)"
  151. >
  152. 编辑
  153. </a-button>
  154. <a-button
  155. size="small"
  156. type="link"
  157. class="button-info"
  158. v-if="record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT'||record.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesEdit')"
  159. @click="handleEdit(record)"
  160. >
  161. 改单
  162. </a-button>
  163. <a-button
  164. size="small"
  165. type="link"
  166. class="button-error"
  167. v-if="record.salesBillSource != 'PURCHASE' && (record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'AUDIT_REJECT')&&$hasPermissions('B_salesDel')"
  168. @click="handleDel(record)"
  169. >
  170. 删除
  171. </a-button>
  172. <a-button
  173. size="small"
  174. type="link"
  175. class="button-error"
  176. v-if="record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT'||record.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesDel')"
  177. @click="handleDel(record)"
  178. >
  179. 取消
  180. </a-button>
  181. <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>
  182. </template>
  183. </s-table>
  184. </a-spin>
  185. <!-- 选择客户弹框 -->
  186. <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  187. <!-- 审核 -->
  188. <auditModal :openModal="visibleAudit" @close="visibleAudit=false" @ok="auditOrder('OUTING_WAREHOUSE')" @fail="auditOrder('AUDIT_REJECT')" />
  189. </a-card>
  190. </template>
  191. <script>
  192. import moment from 'moment'
  193. import getDate from '@/libs/getDate.js'
  194. import rangeDate from '@/views/common/rangeDate.vue'
  195. import { STable, VSelect } from '@/components'
  196. import auditModal from '@/views/common/auditModal.vue'
  197. import chooseCustomModal from './chooseCustomModal.vue'
  198. import custList from '@/views/common/custList.vue'
  199. import { salesList, salesDel, salesWriteAudit, salesCount } from '@/api/sales'
  200. import { findBySalesBillSn } from '@/api/dispatch'
  201. export default {
  202. name: 'TableList',
  203. components: { STable, VSelect, chooseCustomModal, custList, rangeDate, auditModal },
  204. data () {
  205. return {
  206. spinning: false,
  207. tableHeight: 0,
  208. advanced: false, // 高级搜索 展开/关闭
  209. disabled: false, // 查询、重置按钮是否可操作
  210. openModal: false, // 选择客户弹框是否显示
  211. time: [
  212. moment(getDate.getThreeMonthDays().starttime, 'YYYY-MM-DD'),
  213. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  214. ],
  215. // 查询参数
  216. queryParam: {
  217. beginDate: getDate.getThreeMonthDays().starttime,
  218. endDate: getDate.getCurrMonthDays().endtime,
  219. buyerSn: undefined, // 客户名称
  220. salesBillNo: '', // 销售单号
  221. purchaseBillNo: '',
  222. printStatus: undefined,
  223. billStatus: undefined, // 业务状态
  224. financialStatus: undefined // 财务状态
  225. },
  226. totalData: {
  227. totalAmount: 0,
  228. totalCategory: 0,
  229. totalQty: 0,
  230. totalRecord: 0,
  231. totalPushedQty: 0,
  232. totalDispatchQty: 0,
  233. totalCancelQty: 0,
  234. totalUnpushedQty: 0,
  235. totalPushedAmount: 0,
  236. totalCancelAmount: 0,
  237. totalUnpushedAmount: 0,
  238. totalDispatchAmount: 0
  239. },
  240. // 表头
  241. columns: [
  242. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  243. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  244. { title: '单据来源', dataIndex: 'salesBillSourceDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  245. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: 210, align: 'center' },
  246. { title: '采购单号', dataIndex: 'purchaseBillNo', width: 210, align: 'center', customRender: function (text) { return text || '--' } },
  247. { title: '客户名称', dataIndex: 'buyerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  248. { title: '总数量', dataIndex: 'totalQty', scopedSlots: { customRender: 'totalQty' }, width: 100, align: 'center' },
  249. { title: '总售价', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  250. { title: '已下推数量', dataIndex: 'totalPushedQty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  251. { title: '已发货数量', dataIndex: 'totalDispatchQty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  252. { title: '已取消数量', dataIndex: 'totalCancelQty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  253. { title: '待下推数量', dataIndex: 'totalUnpushedQty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  254. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  255. { title: '审核时间', dataIndex: 'auditDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  256. { title: '最近备货时间', dataIndex: 'lastStockUpDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  257. { title: '业务状态', dataIndex: 'billStatusDictValue', width: 110, align: 'center', customRender: function (text) { return text || '--' } },
  258. { title: '财务状态', dataIndex: 'financialStatus', scopedSlots: { customRender: 'financialStatus' }, width: 110, align: 'center' },
  259. { title: '打印次数', dataIndex: 'detailPrintTimes', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  260. { title: '操作', scopedSlots: { customRender: 'action' }, width: 220, align: 'center', fixed: 'right' }
  261. ],
  262. // 加载数据方法 必须为 Promise 对象
  263. loadData: parameter => {
  264. this.disabled = true
  265. delete parameter.tableId
  266. delete parameter.index
  267. if (this.tableHeight == 0) {
  268. this.tableHeight = window.innerHeight - 440
  269. }
  270. // 查询总计
  271. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  272. console.log(res)
  273. this.totalData = Object.assign(this.totalData, res.data || {})
  274. })
  275. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  276. const data = res.data
  277. const no = (data.pageNo - 1) * data.pageSize
  278. for (var i = 0; i < data.list.length; i++) {
  279. data.list[i].no = no + i + 1
  280. }
  281. this.disabled = false
  282. return data
  283. })
  284. },
  285. visibleAudit: false,
  286. auditInfo: null
  287. }
  288. },
  289. methods: {
  290. // 时间 change
  291. dateChange (date) {
  292. this.queryParam.beginDate = date[0]
  293. this.queryParam.endDate = date[1]
  294. },
  295. custChange (val) {
  296. this.queryParam.buyerSn = val.key
  297. },
  298. // 新增
  299. handleAdd () {
  300. this.openModal = true
  301. },
  302. // 选择客户成功
  303. chooseCustomOk (data) {
  304. this.$router.push({ name: 'salesAdd', params: { sn: data.salesBillSn } })
  305. },
  306. // 下推
  307. handleDispatch (row) {
  308. this.spinning = true
  309. findBySalesBillSn({ salesBillSn: row.salesBillSn }).then(res => {
  310. this.spinning = false
  311. if (res.status == 200) {
  312. this.$router.push({ name: 'waitDispatch', params: { salesBillSn: row.salesBillSn, dispatchBillSn: res.data.dispatchBillSn } })
  313. }
  314. })
  315. },
  316. // 审核
  317. handleEexamine (row) {
  318. this.auditInfo = row
  319. this.visibleAudit = true
  320. },
  321. auditOrder (billStatus) {
  322. this.spinning = true
  323. salesWriteAudit({
  324. salesBillSn: this.auditInfo.salesBillSn,
  325. billStatus: billStatus
  326. }).then(res => {
  327. if (res.status == 200) {
  328. this.visibleAudit = false
  329. this.$message.success(res.message)
  330. this.$refs.table.refresh()
  331. this.spinning = false
  332. if (billStatus == 'OUTING_WAREHOUSE') {
  333. this.handleDispatch({ salesBillSn: this.auditInfo.salesBillSn })
  334. }
  335. } else {
  336. this.visibleAudit = false
  337. this.spinning = false
  338. }
  339. })
  340. },
  341. // 详情
  342. handleDetail (row) {
  343. this.$router.push({ name: 'salesDetail', params: { sn: row.salesBillSn } })
  344. },
  345. // 编辑
  346. handleEdit (row) {
  347. this.$router.push({ name: 'salesEdit', params: { sn: row.salesBillSn } })
  348. },
  349. // 删除
  350. handleDel (row) {
  351. const _this = this
  352. this.$confirm({
  353. title: '提示',
  354. content: row.salesBillSource == 'PURCHASE' ? '确认要取消吗?' : '确认要删除吗?',
  355. centered: true,
  356. closable: true,
  357. onOk () {
  358. _this.spinning = true
  359. salesDel({ salesBillSn: row.salesBillSn }).then(res => {
  360. if (res.status == 200) {
  361. _this.$message.success(res.message)
  362. _this.$refs.table.refresh()
  363. _this.spinning = false
  364. } else {
  365. _this.spinning = false
  366. }
  367. })
  368. }
  369. })
  370. },
  371. // 重置
  372. resetSearchForm () {
  373. this.$refs.rangeDate.resetDate(this.time)
  374. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  375. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  376. this.$refs.custList.resetForm()
  377. this.queryParam.buyerSn = undefined
  378. this.queryParam.salesBillNo = ''
  379. this.queryParam.purchaseBillNo = ''
  380. this.queryParam.printStatus = undefined
  381. this.queryParam.billStatus = undefined
  382. this.queryParam.financialStatus = undefined
  383. this.$refs.table.refresh(true)
  384. }
  385. },
  386. beforeRouteEnter (to, from, next) {
  387. next(vm => {
  388. })
  389. }
  390. }
  391. </script>
  392. <style lang="less">
  393. .ssalesManagementList-wrap{
  394. .sTable{
  395. margin-top: 15px;
  396. }
  397. }
  398. </style>