list.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. <template>
  2. <div class="jg-page-wrap salesManagementList-wrap">
  3. <a-card size="small" :bordered="false" class="table-page-search-wrapper">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch">
  6. <a-form layout="inline" @keyup.enter.native="searchForm">
  7. <a-row type="flex" justify="start" :gutter="15">
  8. <a-col :span="6">
  9. <a-form-item label="创建时间">
  10. <rangeDate :allowClear="isByCustQuery" :hasDisabledAreaTime="false" ref="rangeDate" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :span="6">
  14. <a-form-item label="客户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}" :required="isByCustQuery">
  15. <custList ref="custList" @change="custChange"></custList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :span="6" v-if="advanced">
  19. <a-form-item label="收款方式">
  20. <v-select
  21. code="SETTLE_STYLE"
  22. id="salesManagementList-settleStyleSn"
  23. v-model="queryParam.settleStyleSn"
  24. allowClear
  25. placeholder="请选择收款方式"
  26. ></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :span="6" v-if="advanced">
  30. <a-form-item label="业务状态">
  31. <v-select
  32. v-model="queryParam.billStatus"
  33. ref="billStatus"
  34. id="salesManagementList-billStatus"
  35. code="SALES_BILL_STATUS"
  36. placeholder="请选择业务状态"
  37. allowClear></v-select>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :span="6">
  41. <a-form-item label="审核时间">
  42. <rangeDate ref="auditRangeDate" v-model="auditTime" @change="auditDateChange" />
  43. </a-form-item>
  44. </a-col>
  45. <a-col :span="6">
  46. <a-form-item label="销售单号">
  47. <a-input id="salesManagementList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  48. </a-form-item>
  49. </a-col>
  50. <a-col :span="6" v-if="advanced">
  51. <a-form-item label="单据来源">
  52. <v-select
  53. v-model="queryParam.sourceType"
  54. ref="sourceType"
  55. id="salesManagementList-sourceType"
  56. code="SALES_SOURCE"
  57. placeholder="请选择单据来源"
  58. allowClear></v-select>
  59. </a-form-item>
  60. </a-col>
  61. <a-col :span="6" v-if="advanced">
  62. <a-form-item label="财务状态">
  63. <v-select
  64. v-model="queryParam.financialStatus"
  65. ref="financialStatus"
  66. id="salesManagementList-financialStatus"
  67. code="FINANCIAL_RECEIVE_STATUS"
  68. placeholder="请选择财务状态"
  69. allowClear></v-select>
  70. </a-form-item>
  71. </a-col>
  72. <a-col :span="6" v-if="advanced">
  73. <a-form-item label="出库时间">
  74. <rangeDate ref="outWareRangeDate" v-model="outWareTime" @change="outWareDateChange" />
  75. </a-form-item>
  76. </a-col>
  77. <a-col :span="6" v-if="advanced">
  78. <a-form-item label="采购单号">
  79. <a-input id="salesManagementList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
  80. </a-form-item>
  81. </a-col>
  82. <a-col :span="6" v-if="advanced">
  83. <a-form-model-item label="铺货出库">
  84. <v-select code="FLAG" id="salesManagementList-distributionFlag" v-model="queryParam.distributionFlag" allowClear placeholder="请选择是否铺货出库"></v-select>
  85. </a-form-model-item>
  86. </a-col>
  87. <a-col :span="24" style="display:flex;align-items: center;">
  88. <div style="text-align:left;width:50%;">
  89. <a-checkbox v-model="isByCustQuery" id="sales-byCustQuery">按客户查询</a-checkbox>
  90. <a-popover placement="right">
  91. <template slot="content">
  92. 使用此查询时,时间可清空,必须选择一个客户
  93. </template>
  94. <a-icon type="question-circle" />
  95. </a-popover>
  96. </div>
  97. <div style="text-align:left;margin-left: -120px;width:50%;">
  98. <a-button type="primary" :disabled="disabled" @click="searchForm">查询</a-button>
  99. <a-button style="margin-left: 5px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  100. <a-button
  101. type="primary"
  102. v-if="$hasPermissions('B_salesExport')"
  103. class="button-warning"
  104. @click="handleExport"
  105. :disabled="disabled"
  106. :loading="exportLoading"
  107. id="salesManagementList-export">导出</a-button>
  108. <a @click="advanced=!advanced" style="margin-left: 5px">
  109. {{ advanced ? '收起' : '展开' }}
  110. <a-icon :type="advanced ? 'up' : 'down'"/>
  111. </a>
  112. </div>
  113. </a-col>
  114. </a-row>
  115. </a-form>
  116. </div>
  117. </a-card>
  118. <a-card size="small" :bordered="false">
  119. <a-spin :spinning="spinning" tip="Loading...">
  120. <!-- 操作按钮 -->
  121. <div class="table-operator" style="display:flex;align-items:center;justify-content: space-between;">
  122. <div class="alert-message">
  123. 销售单数合计:<strong>{{ totalData&&(totalData.totalRecord || totalData.totalRecord==0) ? totalData.totalRecord : '--' }}</strong>;
  124. 销售款数合计:<strong>{{ totalData&&(totalData.totalCategory || totalData.totalCategory==0) ? totalData.totalCategory : '--' }}</strong>;
  125. 销售数量合计:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  126. 销售金额合计:<strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? toThousands(totalData.totalAmount) : '--' }}</strong>;
  127. </div>
  128. <div class="action-buttons">
  129. <a-button type="primary" class="button-error" v-if="$hasPermissions('B_salesNews')" @click="handleAdd(0)"><a-icon type="plus" /> 新增(零售)</a-button>
  130. <a-button type="primary" class="button-error" v-if="$hasPermissions('B_salesNews')" @click="handleAdd(1)"><a-icon type="plus" /> 新增(铺货)</a-button>
  131. <a-dropdown v-model="showCell">
  132. <a-button type="link" class="button-default"> <a-icon type="setting" /> 显示</a-button>
  133. <a-menu slot="overlay">
  134. <a-menu-item>
  135. <a-checkbox v-model="showDiscount" id="salesQuery-edit-discount">折后总售价</a-checkbox>
  136. </a-menu-item>
  137. </a-menu>
  138. </a-dropdown>
  139. </div>
  140. </div>
  141. <!-- 列表 -->
  142. <s-table
  143. class="sTable fixPagination"
  144. ref="table"
  145. :style="{ height: tableHeight+84+'px' }"
  146. size="small"
  147. :rowKey="(record) => record.id"
  148. :columns="columns"
  149. :data="loadData"
  150. :scroll="{ y:tableHeight }"
  151. :defaultLoadData="false"
  152. bordered>
  153. <!-- 销售单号 -->
  154. <template slot="salesBillNo" slot-scope="text, record">
  155. <span class="table-td-link" v-if="$hasPermissions('B_salesDetail')" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  156. <span v-else>{{ record.salesBillNo }}</span>
  157. <a-badge count="改" :number-style="{ zoom:'80%',marginLeft:'5px' }" v-if="record.billStatus=='SUPERIOR_CHANGE'"></a-badge>
  158. </template>
  159. <!-- 审核 -->
  160. <template slot="audit" slot-scope="text, record">
  161. <stateIcon :title="record.billStatusDictValue" v-if="record.billStatus!='AUDIT_REJECT'" :state="record.billStatus == 'WAIT_OUT_WAREHOUSE'||record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  162. <stateIcon :title="record.billStatusDictValue" v-else :state="0"></stateIcon>
  163. </template>
  164. <!-- 急件 -->
  165. <template slot="oosFlag" slot-scope="text, record">
  166. <stateIcon :state="record.oosFlag==1?'1':'2'"></stateIcon>
  167. </template>
  168. <!-- 出库 -->
  169. <template slot="waitOut" slot-scope="text, record">
  170. <stateIcon :state="record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  171. </template>
  172. <!-- 收款 -->
  173. <template slot="financial" slot-scope="text, record">
  174. <stateIcon :title="record.financialStatusDictValue" :state="record.financialStatus == 'FINISH'?'1':'2'"></stateIcon>
  175. </template>
  176. <!-- 操作 -->
  177. <template slot="action" slot-scope="text, record">
  178. <a-button
  179. size="small"
  180. type="link"
  181. class="button-primary"
  182. v-if="record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')"
  183. @click="handleEexamine(record)"
  184. >审核</a-button>
  185. <a-button
  186. size="small"
  187. type="link"
  188. v-if="record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')"
  189. class="button-primary"
  190. @click="handleSend(record)"
  191. >出库</a-button>
  192. <a-button
  193. size="small"
  194. type="link"
  195. class="button-primary"
  196. v-if="((record.sourceType == 'SATELLITE' || record.sourceType == 'SALES' || record.sourceType == 'TEMPORARY_DISPATCHING') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'AUDIT_REJECT')) && $hasPermissions('B_salesEdit')"
  197. @click="handleEdit(record)"
  198. >
  199. 编辑
  200. </a-button>
  201. <a-button
  202. size="small"
  203. type="link"
  204. class="button-error"
  205. v-if="((record.sourceType == 'SATELLITE' || record.sourceType == 'SALES' || record.sourceType == 'TEMPORARY_DISPATCHING') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel')"
  206. @click="handleDel(record)"
  207. >
  208. 删除
  209. </a-button>
  210. <a-button
  211. size="small"
  212. type="link"
  213. class="button-primary"
  214. v-if="((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesEdit')"
  215. @click="handleEdit(record)"
  216. >
  217. 改单
  218. </a-button>
  219. <a-button
  220. size="small"
  221. type="link"
  222. class="button-error"
  223. v-if="((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel')"
  224. @click="handleDel(record, 'cancel')"
  225. >
  226. 取消
  227. </a-button>
  228. <span v-if="!(record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')) && !(record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')) && !(((record.sourceType == 'SATELLITE' || record.sourceType == 'SALES' || record.sourceType == 'TEMPORARY_DISPATCHING') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'AUDIT_REJECT')) && $hasPermissions('B_salesEdit')) && !(((record.sourceType == 'SATELLITE' || record.sourceType == 'SALES' || record.sourceType == 'TEMPORARY_DISPATCHING') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel'))">
  229. <span v-if="!(((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) &&$hasPermissions('B_salesEdit')) && !(((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel'))">--</span>
  230. </span>
  231. </template>
  232. </s-table>
  233. </a-spin>
  234. <!-- 选择客户弹框 -->
  235. <choose-custom-modal :show="openModal" :distributionFlag="distributionFlag" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  236. <!-- 审核 -->
  237. <auditModal :openModal="visibleAudit" :spinning="spinningAudit" @close="visibleAudit=false" @ok="auditOrder('WAIT_OUT_WAREHOUSE')" @fail="auditOrder('AUDIT_REJECT')" />
  238. </a-card>
  239. </div>
  240. </template>
  241. <script>
  242. import { commonMixin } from '@/utils/mixin'
  243. import getDate from '@/libs/getDate.js'
  244. import { STable, VSelect } from '@/components'
  245. import chooseCustomModal from './chooseCustomModal.vue'
  246. import auditModal from '@/views/common/auditModal.vue'
  247. import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount, salesExport } from '@/api/sales'
  248. import rangeDate from '@/views/common/rangeDate.vue'
  249. import custList from '@/views/common/custList.vue'
  250. import { downloadExcel } from '@/libs/JGPrint.js'
  251. import stateIcon from '@/views/common/stateIcon'
  252. import moment from 'moment'
  253. export default {
  254. name: 'SalesList',
  255. components: { STable, VSelect, chooseCustomModal, rangeDate, auditModal, custList, stateIcon },
  256. mixins: [commonMixin],
  257. data () {
  258. const _this = this
  259. return {
  260. spinning: false,
  261. tableHeight: 0,
  262. advanced: true, // 高级搜索 展开/关闭
  263. disabled: false, // 查询、重置按钮是否可操作
  264. exportLoading: false, // 导出loading
  265. openModal: false, // 选择客户弹框是否显示
  266. isByCustQuery: false, // 是否按客户查询
  267. showDiscount: false,
  268. showCell: false,
  269. time: [
  270. getDate.getMonthDays(3).starttime,
  271. getDate.getMonthDays(3).endtime
  272. ],
  273. auditTime: [],
  274. outWareTime: [],
  275. // 查询参数
  276. queryParam: {
  277. beginDate: getDate.getMonthDays(3).starttime,
  278. endDate: getDate.getMonthDays(3).endtime,
  279. auditBeginDate: '',
  280. auditEndDate: '',
  281. outWarehouseBeginDate: '',
  282. outWarehouseEndDate: '',
  283. buyerNameCurrent: undefined, // 客户名称
  284. buyerSn: undefined,
  285. salesBillNo: '', // 销售单号
  286. purchaseBillNo: '', // 采购单号
  287. payType: undefined, // 支付方式
  288. settleStyleSn: undefined, // 收款方式
  289. billStatus: undefined, // 业务状态
  290. financialStatus: undefined, // 财务状态
  291. sourceType: undefined,
  292. distributionFlag: undefined
  293. },
  294. totalData: {
  295. totalAmount: 0,
  296. totalCategory: 0,
  297. totalQty: 0,
  298. totalRecord: 0
  299. },
  300. selType: '0', // 0零售 1铺货
  301. // 加载数据方法 必须为 Promise 对象
  302. loadData: parameter => {
  303. this.disabled = true
  304. this.spinning = true
  305. // 查询总计
  306. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  307. console.log(res, 'res')
  308. this.totalData = Object.assign(this.totalData, res.data || {})
  309. })
  310. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  311. let data
  312. if (res.status == 200) {
  313. data = res.data
  314. const no = (data.pageNo - 1) * data.pageSize
  315. for (var i = 0; i < data.list.length; i++) {
  316. data.list[i].no = no + i + 1
  317. }
  318. this.disabled = false
  319. }
  320. console.log(res, 'res')
  321. this.spinning = false
  322. return data
  323. })
  324. },
  325. visibleAudit: false,
  326. auditInfo: null,
  327. spinningAudit: false,
  328. distributionFlag: '0'
  329. }
  330. },
  331. computed: {
  332. columns () {
  333. const _this = this
  334. const arr = [
  335. { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
  336. { title: '来源', dataIndex: 'sourceTypeDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  337. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: '9%', align: 'center' },
  338. { title: '客户名称', dataIndex: 'buyerNameCurrent', align: 'center', width: '15%', customRender: function (text) { return text || '--' } },
  339. { title: '总款数', dataIndex: 'totalCategory', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  340. { title: '总数量', dataIndex: 'totalQty', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  341. { title: '总售价', dataIndex: 'totalAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  342. // { title: '折扣金额', dataIndex: 'discountAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  343. // { title: '折后总售价', dataIndex: 'discountedAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  344. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  345. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  346. { title: '审核时间', dataIndex: 'auditDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  347. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  348. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '2%', align: 'center' },
  349. { title: '急件', scopedSlots: { customRender: 'oosFlag' }, width: '2%', align: 'center' },
  350. { title: '出库', scopedSlots: { customRender: 'waitOut' }, width: '2%', align: 'center' },
  351. { title: '收款', scopedSlots: { customRender: 'financial' }, width: '2%', align: 'center' },
  352. // { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  353. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  354. ]
  355. // 显示折扣
  356. if (this.showDiscount) {
  357. arr.splice(7, 0, { title: '折扣金额', dataIndex: 'discountAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  358. arr.splice(8, 0, { title: '折后总售价', dataIndex: 'discountedAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  359. }
  360. return arr
  361. }
  362. },
  363. methods: {
  364. // 时间 change
  365. dateChange (date) {
  366. this.queryParam.beginDate = date[0]
  367. this.queryParam.endDate = date[1]
  368. },
  369. auditDateChange (date) {
  370. this.auditTime = date
  371. this.queryParam.auditBeginDate = date[0]
  372. this.queryParam.auditEndDate = date[1]
  373. },
  374. outWareDateChange (date) {
  375. this.outWareTime = date
  376. this.queryParam.outWarehouseBeginDate = date[0]
  377. this.queryParam.outWarehouseEndDate = date[1]
  378. },
  379. custChange (v, row) {
  380. console.log(v, row)
  381. if (row && row.customerSn) {
  382. this.queryParam.buyerSn = row.customerSn
  383. this.queryParam.buyerNameCurrent = undefined
  384. } else {
  385. this.queryParam.buyerNameCurrent = v
  386. this.queryParam.buyerSn = undefined
  387. }
  388. },
  389. // 新增
  390. handleAdd (flag) {
  391. this.openModal = true
  392. this.distributionFlag = flag
  393. },
  394. // 审核
  395. handleEexamine (row) {
  396. this.auditInfo = row
  397. this.visibleAudit = true
  398. },
  399. auditOrder (billStatus) {
  400. this.spinningAudit = true
  401. salesWriteAudit({
  402. id: this.auditInfo.id,
  403. billStatus: billStatus
  404. }).then(res => {
  405. if (res.status == 200) {
  406. this.visibleAudit = false
  407. this.$message.success(res.message)
  408. this.$refs.table.refresh()
  409. this.spinningAudit = false
  410. } else {
  411. this.visibleAudit = false
  412. this.spinningAudit = false
  413. }
  414. })
  415. },
  416. // 出库
  417. handleSend (row) {
  418. const _this = this
  419. this.$confirm({
  420. title: '提示',
  421. content: '确认要出库吗?',
  422. centered: true,
  423. closable: true,
  424. onOk () {
  425. _this.spinning = true
  426. salesWriteStockOut({
  427. salesBillSn: row.salesBillSn
  428. }).then(res => {
  429. if (res.status == 200) {
  430. _this.$message.success(res.message)
  431. _this.$refs.table.refresh()
  432. _this.spinning = false
  433. } else {
  434. _this.spinning = false
  435. }
  436. })
  437. }
  438. })
  439. },
  440. // 详情
  441. handleDetail (row) {
  442. this.$router.push({ name: 'salesNewDetail', params: { sn: row.salesBillSn } })
  443. },
  444. // 编辑
  445. handleEdit (row) {
  446. this.$router.push({ name: 'salesNewEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  447. },
  448. // 选择客户成功
  449. chooseCustomOk (data) {
  450. this.$router.push({ name: 'salesNewAdd', params: { id: data.id, sn: data.salesBillSn, priceType: data.priceType } })
  451. },
  452. // 删除
  453. handleDel (row, type) {
  454. const _this = this
  455. let content = '确认要删除吗?'
  456. if (type == 'cancel') {
  457. content = '确认要取消吗?'
  458. }
  459. this.$confirm({
  460. title: '提示',
  461. content: <div><div style='font-size:16px;margin-bottom:10px;'>{content}</div><div>销售单号:{row.salesBillNo}</div><div>客户名称:{row.buyerNameCurrent}</div></div>,
  462. centered: true,
  463. closable: true,
  464. onOk () {
  465. _this.spinning = true
  466. salesDel({ id: row.id, mainFlag: 1 }).then(res => {
  467. if (res.status == 200) {
  468. _this.$message.success(res.message)
  469. _this.$refs.table.refresh()
  470. _this.spinning = false
  471. } else {
  472. _this.spinning = false
  473. }
  474. })
  475. }
  476. })
  477. },
  478. searchForm (flag) {
  479. if (!this.isByCustQuery) {
  480. const a = moment(this.queryParam.beginDate)
  481. const b = moment(this.queryParam.endDate)
  482. if (b.diff(a, 'days') > 730) {
  483. this.$message.info('最多只能选择2年的时间区间')
  484. return false
  485. }
  486. this.$refs.table.refresh(!flag)
  487. } else {
  488. if (this.queryParam.buyerSn) {
  489. this.$refs.table.refresh(!flag)
  490. } else {
  491. this.$message.info('请选择客户')
  492. return false
  493. }
  494. }
  495. },
  496. // 重置
  497. resetSearchForm () {
  498. this.resetData()
  499. this.$refs.table.refresh(true)
  500. },
  501. // 重置数据
  502. resetData (flag) {
  503. this.$refs.rangeDate.resetDate(flag ? '' : this.time)
  504. this.queryParam.beginDate = flag ? '' : getDate.getMonthDays(3).starttime
  505. this.queryParam.endDate = flag ? '' : getDate.getMonthDays(3).endtime
  506. this.queryParam.auditBeginDate = ''
  507. this.queryParam.auditEndDate = ''
  508. this.queryParam.outWarehouseBeginDate = ''
  509. this.queryParam.outWarehouseEndDate = ''
  510. this.auditTime = []
  511. this.outWareTime = []
  512. if (this.advanced) {
  513. this.$refs.auditRangeDate.resetDate('')
  514. this.$refs.outWareRangeDate.resetDate('')
  515. }
  516. this.queryParam.buyerNameCurrent = undefined
  517. this.queryParam.buyerSn = undefined
  518. this.queryParam.salesBillNo = ''
  519. this.queryParam.purchaseBillNo = ''
  520. this.queryParam.payType = undefined
  521. this.queryParam.settleStyleSn = undefined
  522. this.queryParam.billStatus = undefined
  523. this.queryParam.financialStatus = undefined
  524. this.queryParam.sourceType = undefined
  525. this.queryParam.distributionFlag = undefined
  526. this.$refs.custList.resetForm()
  527. if (!flag) {
  528. this.setIsHomeNav(this.$route.name, null)
  529. }
  530. },
  531. // 导出
  532. handleExport () {
  533. const _this = this
  534. const params = this.queryParam
  535. params.showDiscountAmountFlag = this.showDiscount ? 1 : 0
  536. this.exportLoading = true
  537. _this.spinning = true
  538. salesExport(params).then(res => {
  539. this.exportLoading = false
  540. _this.spinning = false
  541. if (res.type == 'application/json') {
  542. var reader = new FileReader()
  543. reader.addEventListener('loadend', function () {
  544. const obj = JSON.parse(reader.result)
  545. _this.$notification.error({
  546. message: '提示',
  547. description: obj.message
  548. })
  549. })
  550. reader.readAsText(res)
  551. } else {
  552. downloadExcel(res, '销售列表')
  553. }
  554. })
  555. },
  556. setTableH () {
  557. const tableSearchH = this.$refs.tableSearch.offsetHeight
  558. this.tableHeight = window.innerHeight - tableSearchH - 267
  559. },
  560. pageInit () {
  561. const _this = this
  562. this.$nextTick(() => { // 页面渲染完成后的回调
  563. _this.setTableH()
  564. })
  565. // 是否打开的页签
  566. const a = this.$store.state.app.isNewTab
  567. // 是否要刷新列表
  568. const b = this.$store.state.app.updateList
  569. // 是否从首页点击进入
  570. const isHomeNav = this.getIsHomeNav()[this.$route.name]
  571. console.log(a, b)
  572. // 从首页进入,判断式新建还式待办查询
  573. if (isHomeNav) {
  574. // 新增
  575. if (isHomeNav.type == 'new') {
  576. this.resetSearchForm()
  577. this.openModal = true
  578. }
  579. // 待办
  580. if (isHomeNav.type == 'todo') {
  581. this.resetData(true)
  582. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  583. this.$refs.rangeDate.resetDate([this.queryParam.beginDate, this.queryParam.endDate])
  584. this.$refs.table.refresh(true)
  585. }
  586. } else {
  587. // 如果是新页签打开,则重置当前页面
  588. if (a && !b) {
  589. this.resetSearchForm()
  590. }
  591. }
  592. // 仅刷新列表,不重置页面
  593. if (b || a == b) {
  594. this.$refs.table.refresh()
  595. }
  596. }
  597. },
  598. watch: {
  599. advanced (newValue, oldValue) {
  600. const _this = this
  601. this.$nextTick(() => { // 页面渲染完成后的回调
  602. _this.setTableH()
  603. })
  604. },
  605. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  606. this.setTableH()
  607. },
  608. isByCustQuery (newValue, oldValue) {
  609. if (!newValue) {
  610. this.resetSearchForm()
  611. }
  612. }
  613. },
  614. activated () {
  615. this.pageInit()
  616. },
  617. beforeRouteEnter (to, from, next) {
  618. next(vm => {
  619. })
  620. }
  621. }
  622. </script>