list.vue 14 KB

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