list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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. <v-select
  46. v-model="queryParam.payType"
  47. ref="payType"
  48. id="salesManagementList-payType"
  49. code="PAY_TYPE"
  50. placeholder="请选择支付方式"
  51. allowClear></v-select>
  52. </a-form-item>
  53. </a-col>
  54. <a-col :md="6" :sm="24">
  55. <a-form-item label="收款方式">
  56. <v-select
  57. v-model="queryParam.settleStyle"
  58. ref="settleStyle"
  59. id="salesManagementList-settleStyle"
  60. code="SETTLE_STYLE_NAME"
  61. placeholder="请选择收款方式"
  62. allowClear></v-select>
  63. </a-form-item>
  64. </a-col>
  65. <a-col :md="6" :sm="24">
  66. <a-form-item label="业务状态">
  67. <v-select
  68. v-model="queryParam.billStatus"
  69. ref="billStatus"
  70. id="salesManagementList-billStatus"
  71. code="BILL_STATUS"
  72. placeholder="请选择业务状态"
  73. allowClear></v-select>
  74. </a-form-item>
  75. </a-col>
  76. <a-col :md="6" :sm="24">
  77. <a-form-item label="财务状态">
  78. <v-select
  79. v-model="queryParam.financialStatus"
  80. ref="financialStatus"
  81. id="salesManagementList-financialStatus"
  82. code="FINANCIAL_STATUS"
  83. placeholder="请选择财务状态"
  84. allowClear></v-select>
  85. </a-form-item>
  86. </a-col>
  87. </template>
  88. <a-col :md="6" :sm="24">
  89. <span class="table-page-search-submitButtons">
  90. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  91. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  92. <a @click="advanced=!advanced" style="margin-left: 8px">
  93. {{ advanced ? '收起' : '展开' }}
  94. <a-icon :type="advanced ? 'up' : 'down'"/>
  95. </a>
  96. </span>
  97. </a-col>
  98. </a-row>
  99. </a-form>
  100. </div>
  101. <!-- 操作按钮 -->
  102. <div class="table-operator">
  103. <a-button type="primary" @click="handleAdd">新增</a-button>
  104. </div>
  105. <!-- alert -->
  106. <a-alert type="info" showIcon style="margin-bottom:15px">
  107. <div slot="message">
  108. 总售价:<strong>{{ totalData.totalAmount }}</strong>元;
  109. 总单数:<strong>{{ totalData.totalRecord }}</strong>;
  110. 总款数:<strong>{{ totalData.totalCategory }}</strong>;
  111. 总数量:<strong>{{ totalData.totalQty }}</strong>;
  112. </div>
  113. </a-alert>
  114. <!-- 列表 -->
  115. <s-table
  116. class="sTable"
  117. ref="table"
  118. size="default"
  119. :rowKey="(record) => record.id"
  120. :columns="columns"
  121. :data="loadData"
  122. :scroll="{ x: 2040, y:300 }"
  123. bordered>
  124. <!-- 业务/审核状态 -->
  125. <template slot="billStatus" slot-scope="text, record">
  126. <a-tag :color="record.state=='FINISH'?'green':'red'" >{{ record.billStatus }}</a-tag>
  127. </template>
  128. <!-- 财务状态 -->
  129. <template slot="financialStatus" slot-scope="text, record">
  130. <a-tag :color="record.state==1?'green':'red'" >{{ record.financialStatus }}</a-tag>
  131. </template>
  132. <!-- 操作 -->
  133. <template slot="action" slot-scope="text, record">
  134. <a-button size="small" type="primary" class="button-warning" @click="handleEexamine(record)" id="salesManagementList-eexamine-btn">审核</a-button>
  135. <a-button size="small" type="primary" class="button-primary" @click="handleSend(record)" id="salesManagementList-send-btn">出库</a-button>
  136. <a-button size="small" type="primary" class="button-success" @click="handleDetail(record)" id="salesManagementList-detail-btn">详情</a-button>
  137. <a-button size="small" type="primary" class="button-info" @click="handleEdit(record)" id="salesManagementList-edit-btn">编辑</a-button>
  138. <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="salesManagementList-del-btn">删除</a-button>
  139. </template>
  140. </s-table>
  141. <!-- 选择客户弹框 -->
  142. <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  143. </a-card>
  144. </template>
  145. <script>
  146. import moment from 'moment'
  147. import { STable, VSelect } from '@/components'
  148. import chooseCustomModal from './chooseCustomModal.vue'
  149. import { custAllList } from '@/api/customer'
  150. import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount } from '@/api/sales'
  151. export default {
  152. name: 'TableList',
  153. components: { STable, VSelect, chooseCustomModal },
  154. data () {
  155. return {
  156. advanced: false, // 高级搜索 展开/关闭
  157. disabled: false, // 查询、重置按钮是否可操作
  158. dateFormat: 'YYYY-MM-DD',
  159. time: [], // 创建时间
  160. openModal: false, // 选择客户弹框是否显示
  161. custAllList: [], // 客户 下拉数据
  162. // 查询参数
  163. queryParam: {
  164. buyerName: undefined, // 客户名称
  165. salesBillNo: '', // 销售单号
  166. purchaseBillNo: '', // 采购单号
  167. payType: undefined, // 支付方式
  168. settleStyle: undefined, // 收款方式
  169. billStatus: undefined, // 业务状态
  170. financialStatus: undefined // 财务状态
  171. },
  172. totalData: {
  173. totalAmount: 0,
  174. totalCategory: 0,
  175. totalQty: 0,
  176. totalRecord: 0
  177. },
  178. // 表头
  179. columns: [
  180. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  181. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  182. { title: '销售单号', dataIndex: 'salesBillNo', width: 180, align: 'center' },
  183. { title: '采购单号', dataIndex: 'purchaseBillNo', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  184. { title: '客户名称', dataIndex: 'buyerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  185. { title: '总款数', dataIndex: 'totalCategory', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  186. { title: '总数量', dataIndex: 'totalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  187. { title: '总售价', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  188. { title: '收款方式', dataIndex: 'settleStyle', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  189. { title: '审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  190. { title: '急件', dataIndex: 'urgentFlag', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  191. { title: '业务状态', scopedSlots: { customRender: 'billStatus' }, width: 110, align: 'center' },
  192. { title: '财务状态', scopedSlots: { customRender: 'financialStatus' }, width: 110, align: 'center' },
  193. { title: '操作', scopedSlots: { customRender: 'action' }, width: 300, align: 'center', fixed: 'right' }
  194. ],
  195. // 加载数据方法 必须为 Promise 对象
  196. loadData: parameter => {
  197. this.disabled = true
  198. // 创建时间
  199. if (this.time && this.time.length > 0) {
  200. this.queryParam.beginDate = moment(this.time[0]).format(this.dateFormat)
  201. this.queryParam.endDate = moment(this.time[1]).format(this.dateFormat)
  202. } else {
  203. this.queryParam.beginDate = undefined
  204. this.queryParam.endDate = undefined
  205. }
  206. // 查询总计
  207. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  208. console.log(res)
  209. this.totalData = Object.assign(this.totalData, res.data || {})
  210. })
  211. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  212. const data = res.data
  213. const no = (data.pageNo - 1) * data.pageSize
  214. for (var i = 0; i < data.list.length; i++) {
  215. data.list[i].no = no + i + 1
  216. }
  217. this.disabled = false
  218. return data
  219. })
  220. }
  221. }
  222. },
  223. methods: {
  224. // 不可选日期
  225. disabledDate (date, dateStrings) {
  226. return date && date.valueOf() > Date.now()
  227. },
  228. // 新增
  229. handleAdd () {
  230. this.openModal = true
  231. },
  232. // 选择客户成功
  233. chooseCustomOk (data) {
  234. this.$router.push({ name: 'salesAdd', params: { id: data.id, sn: data.salesBillSn } })
  235. },
  236. // 审核
  237. handleEexamine (row) {
  238. const _this = this
  239. this.$confirm({
  240. title: '提示',
  241. content: '请点击下方按钮确认操作?',
  242. centered: true,
  243. okText: '审核通过',
  244. cancelText: '审核不通过',
  245. onOk () {
  246. _this.auditOrder(row.id, 'AUDIT_PASS')
  247. },
  248. onCancel () {
  249. _this.auditOrder(row.id, 'AUDIT_REJECT')
  250. }
  251. })
  252. },
  253. auditOrder (id, billStatus) {
  254. salesWriteAudit({
  255. id,
  256. billStatus
  257. }).then(res => {
  258. if (res.status == 200) {
  259. this.$message.success(res.message)
  260. this.$refs.table.refresh()
  261. }
  262. })
  263. },
  264. // 出库
  265. handleSend (row) {
  266. const _this = this
  267. this.$confirm({
  268. title: '提示',
  269. content: '确认要出库吗?',
  270. centered: true,
  271. onOk () {
  272. salesWriteStockOut({
  273. id: row.id,
  274. salesBillSn: row.salesBillSn
  275. }).then(res => {
  276. if (res.status == 200) {
  277. _this.$message.success(res.message)
  278. _this.$refs.table.refresh()
  279. }
  280. })
  281. }
  282. })
  283. },
  284. // 详情
  285. handleDetail (row) {
  286. this.$router.push({ name: 'salesDetail', params: { id: row.id, sn: row.salesBillSn } })
  287. },
  288. // 编辑
  289. handleEdit (row) {
  290. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn } })
  291. },
  292. // 删除
  293. handleDel (row) {
  294. const _this = this
  295. this.$confirm({
  296. title: '提示',
  297. content: '确认要删除吗?',
  298. centered: true,
  299. onOk () {
  300. salesDel({ id: row.id }).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. getCustAllList () {
  311. const _this = this
  312. custAllList().then(res => {
  313. if (res.status == 200) {
  314. _this.custAllList = res.data || []
  315. } else {
  316. _this.custAllList = []
  317. }
  318. })
  319. },
  320. // 重置
  321. resetSearchForm () {
  322. this.queryParam.buyerName = undefined
  323. this.queryParam.salesBillNo = ''
  324. this.queryParam.purchaseBillNo = ''
  325. this.queryParam.payType = undefined
  326. this.queryParam.settleStyle = undefined
  327. this.queryParam.billStatus = undefined
  328. this.queryParam.financialStatus = undefined
  329. this.time = []
  330. this.$refs.table.refresh(true)
  331. },
  332. filterOption (input, option) {
  333. return (
  334. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  335. )
  336. }
  337. },
  338. beforeRouteEnter (to, from, next) {
  339. next(vm => {
  340. vm.getCustAllList()
  341. })
  342. }
  343. }
  344. </script>
  345. <style lang="less">
  346. .ssalesManagementList-wrap{
  347. .sTable{
  348. margin-top: 15px;
  349. }
  350. }
  351. </style>