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