list.vue 14 KB

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