list.vue 25 KB

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