list.vue 26 KB

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