list.vue 15 KB

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