list.vue 14 KB

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