list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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. id="salesManagementList-eexamine-btn">审核</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. id="salesManagementList-send-btn">出库</a-button>
  139. <a-button
  140. size="small"
  141. type="link"
  142. class="button-info"
  143. v-if="record.billStatus !== 'CANCEL' && record.billStatus !== 'FINISH' && record.billStatus != 'WAIT_OUT_WAREHOUSE'"
  144. @click="handleEdit(record)"
  145. id="salesManagementList-edit-btn">编辑</a-button>
  146. <a-button
  147. size="small"
  148. type="link"
  149. class="button-error"
  150. v-if="record.billStatus !== 'FINISH' && record.financialStatus !== 'FINISH'"
  151. @click="handleDel(record)"
  152. id="salesManagementList-del-btn">删除</a-button>
  153. </template>
  154. </s-table>
  155. <!-- 选择客户弹框 -->
  156. <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  157. </a-card>
  158. </template>
  159. <script>
  160. import moment from 'moment'
  161. import { STable, VSelect } from '@/components'
  162. import chooseCustomModal from './chooseCustomModal.vue'
  163. import { custAllList } from '@/api/customer'
  164. import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount } from '@/api/sales'
  165. import { settleStyleQueryAll } from '@/api/settleStyle'
  166. export default {
  167. name: 'TableList',
  168. components: { STable, VSelect, chooseCustomModal },
  169. data () {
  170. return {
  171. tableHeight: 0,
  172. advanced: false, // 高级搜索 展开/关闭
  173. disabled: false, // 查询、重置按钮是否可操作
  174. dateFormat: 'YYYY-MM-DD',
  175. time: [], // 创建时间
  176. openModal: false, // 选择客户弹框是否显示
  177. custAllList: [], // 客户 下拉数据
  178. settleStyleList: [], // 收款方式
  179. // 查询参数
  180. queryParam: {
  181. buyerName: undefined, // 客户名称
  182. salesBillNo: '', // 销售单号
  183. purchaseBillNo: '', // 采购单号
  184. payType: undefined, // 支付方式
  185. settleStyleSn: undefined, // 收款方式
  186. billStatus: undefined, // 业务状态
  187. financialStatus: undefined // 财务状态
  188. },
  189. totalData: {
  190. totalAmount: 0,
  191. totalCategory: 0,
  192. totalQty: 0,
  193. totalRecord: 0
  194. },
  195. // 表头
  196. columns: [
  197. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  198. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  199. { title: '来源', dataIndex: 'salesBillSourceDictValue', width: 120, align: 'center' },
  200. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: 180, align: 'center' },
  201. { title: '采购单号', dataIndex: 'purchaseBillNo', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  202. { title: '客户名称', dataIndex: 'buyerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  203. { title: '总款数', dataIndex: 'totalCategory', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  204. { title: '总数量', dataIndex: 'totalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  205. { title: '总售价', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  206. { title: '收款方式', dataIndex: 'settleStyleEntity.name', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  207. { title: '审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  208. { title: '急件', dataIndex: 'oosFlag', scopedSlots: { customRender: 'oosFlag' }, width: 100, align: 'center' },
  209. { title: '业务状态', dataIndex: 'billStatusDictValue', width: 110, align: 'center' },
  210. { title: '财务状态', dataIndex: 'financialStatus', scopedSlots: { customRender: 'financialStatus' }, width: 110, align: 'center' },
  211. { title: '操作', scopedSlots: { customRender: 'action' }, width: 280, align: 'center', fixed: 'right' }
  212. ],
  213. // 加载数据方法 必须为 Promise 对象
  214. loadData: parameter => {
  215. this.disabled = true
  216. if (this.tableHeight == 0) {
  217. this.tableHeight = window.innerHeight - 320
  218. }
  219. // 创建时间
  220. if (this.time && this.time.length > 0) {
  221. this.queryParam.beginDate = moment(this.time[0]).format(this.dateFormat)
  222. this.queryParam.endDate = moment(this.time[1]).format(this.dateFormat)
  223. } else {
  224. this.queryParam.beginDate = undefined
  225. this.queryParam.endDate = undefined
  226. }
  227. // 查询总计
  228. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  229. console.log(res)
  230. this.totalData = Object.assign(this.totalData, res.data || {})
  231. })
  232. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  233. const data = res.data
  234. const no = (data.pageNo - 1) * data.pageSize
  235. for (var i = 0; i < data.list.length; i++) {
  236. data.list[i].no = no + i + 1
  237. }
  238. this.disabled = false
  239. return data
  240. })
  241. }
  242. }
  243. },
  244. methods: {
  245. // 不可选日期
  246. disabledDate (date, dateStrings) {
  247. return date && date.valueOf() > Date.now()
  248. },
  249. // 新增
  250. handleAdd () {
  251. this.openModal = true
  252. },
  253. // 选择客户成功
  254. chooseCustomOk (data) {
  255. this.$router.push({ name: 'salesAdd', params: { id: data.id, sn: data.salesBillSn, priceType: data.priceType } })
  256. },
  257. // 审核
  258. handleEexamine (row) {
  259. const _this = this
  260. this.$confirm({
  261. title: '提示',
  262. content: '请点击下方按钮确认操作?',
  263. centered: true,
  264. closable: true,
  265. okText: '审核通过',
  266. cancelText: '审核不通过',
  267. onOk () {
  268. _this.auditOrder(row.id, 'WAIT_OUT_WAREHOUSE')
  269. },
  270. onCancel (e) {
  271. if (!e.triggerCancel) {
  272. _this.auditOrder(row.id, 'AUDIT_REJECT')
  273. }
  274. _this.$destroyAll()
  275. }
  276. })
  277. },
  278. auditOrder (id, billStatus) {
  279. salesWriteAudit({
  280. id,
  281. billStatus
  282. }).then(res => {
  283. if (res.status == 200) {
  284. this.$message.success(res.message)
  285. this.$refs.table.refresh()
  286. }
  287. })
  288. },
  289. // 出库
  290. handleSend (row) {
  291. const _this = this
  292. this.$confirm({
  293. title: '提示',
  294. content: '确认要出库吗?',
  295. centered: true,
  296. closable: true,
  297. onOk () {
  298. salesWriteStockOut({
  299. salesBillSn: row.salesBillSn
  300. }).then(res => {
  301. if (res.status == 200) {
  302. _this.$message.success(res.message)
  303. _this.$refs.table.refresh()
  304. }
  305. })
  306. }
  307. })
  308. },
  309. // 详情
  310. handleDetail (row) {
  311. this.$router.push({ name: 'salesDetail', params: { sn: row.salesBillSn } })
  312. },
  313. // 编辑
  314. handleEdit (row) {
  315. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  316. },
  317. // 删除
  318. handleDel (row) {
  319. const _this = this
  320. this.$confirm({
  321. title: '提示',
  322. content: '确认要删除吗?',
  323. centered: true,
  324. closable: true,
  325. onOk () {
  326. salesDel({ id: row.id }).then(res => {
  327. if (res.status == 200) {
  328. _this.$message.success(res.message)
  329. _this.$refs.table.refresh()
  330. }
  331. })
  332. }
  333. })
  334. },
  335. // 客户无分页列表数据
  336. getCustAllList () {
  337. const _this = this
  338. custAllList().then(res => {
  339. if (res.status == 200) {
  340. _this.custAllList = res.data || []
  341. } else {
  342. _this.custAllList = []
  343. }
  344. })
  345. },
  346. // 重置
  347. resetSearchForm () {
  348. this.queryParam.buyerName = undefined
  349. this.queryParam.salesBillNo = ''
  350. this.queryParam.purchaseBillNo = ''
  351. this.queryParam.payType = undefined
  352. this.queryParam.settleStyleSn = undefined
  353. this.queryParam.billStatus = undefined
  354. this.queryParam.financialStatus = undefined
  355. this.time = []
  356. this.$refs.table.refresh(true)
  357. },
  358. filterOption (input, option) {
  359. return (
  360. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  361. )
  362. },
  363. // 获取收款方式
  364. getSettleStyle () {
  365. settleStyleQueryAll().then(res => {
  366. if (res.status == 200) {
  367. this.settleStyleList = res.data
  368. }
  369. })
  370. }
  371. },
  372. beforeRouteEnter (to, from, next) {
  373. next(vm => {
  374. vm.getCustAllList()
  375. vm.getSettleStyle()
  376. })
  377. }
  378. }
  379. </script>
  380. <style lang="less">
  381. .ssalesManagementList-wrap{
  382. .sTable{
  383. margin-top: 15px;
  384. }
  385. }
  386. </style>