list.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  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="客户名称" :required="isByCustQuery">
  15. <custList ref="custList" style="width: 100%;" @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. style="width: 100%;"
  38. v-model="queryParam.sourceType"
  39. ref="sourceType"
  40. id="salesManagementList-sourceType"
  41. code="SALES_SOURCE"
  42. placeholder="请选择单据来源"
  43. allowClear></v-select>
  44. </a-form-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-form-item label="收款方式">
  48. <v-select
  49. code="SETTLE_STYLE"
  50. id="salesManagementList-settleStyleSn"
  51. v-model="queryParam.settleStyleSn"
  52. allowClear
  53. placeholder="请选择收款方式"
  54. ></v-select>
  55. </a-form-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-item label="业务状态">
  59. <v-select
  60. v-model="queryParam.billStatus"
  61. ref="billStatus"
  62. id="salesManagementList-billStatus"
  63. code="SALES_BILL_STATUS"
  64. placeholder="请选择业务状态"
  65. allowClear></v-select>
  66. </a-form-item>
  67. </a-col>
  68. <a-col :md="6" :sm="24">
  69. <a-form-item label="财务状态">
  70. <v-select
  71. v-model="queryParam.financialStatus"
  72. ref="financialStatus"
  73. id="salesManagementList-financialStatus"
  74. code="FINANCIAL_RECEIVE_STATUS"
  75. placeholder="请选择财务状态"
  76. allowClear></v-select>
  77. </a-form-item>
  78. </a-col>
  79. <a-col :md="6" :sm="24">
  80. <a-form-item label="采购单号">
  81. <a-input id="salesManagementList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
  82. </a-form-item>
  83. </a-col>
  84. <a-col :span="6">
  85. <a-form-model-item label="铺货出库">
  86. <v-select code="FLAG" id="salesManagementList-distributionFlag" v-model="queryParam.distributionFlag" allowClear placeholder="请选择是否铺货出库"></v-select>
  87. </a-form-model-item>
  88. </a-col>
  89. </template>
  90. <a-col :md="6" :sm="24">
  91. <span class="table-page-search-submitButtons">
  92. <a-button type="primary" :disabled="disabled" @click="searchForm">查询</a-button>
  93. <a-button style="margin-left: 5px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  94. <a-button
  95. type="primary"
  96. v-if="$hasPermissions('B_salesExport')"
  97. class="button-warning"
  98. @click="handleExport"
  99. :disabled="disabled"
  100. :loading="exportLoading"
  101. id="salesManagementList-export">导出</a-button>
  102. <a @click="advanced=!advanced" style="margin-left: 5px">
  103. {{ advanced ? '收起' : '展开' }}
  104. <a-icon :type="advanced ? 'up' : 'down'"/>
  105. </a>
  106. </span>
  107. </a-col>
  108. </a-row>
  109. </a-form>
  110. </div>
  111. <!-- 操作按钮 -->
  112. <div class="table-operator" style="display:flex;align-items: center;justify-content: space-between;">
  113. <div>
  114. <a-button type="primary" class="button-error" v-if="$hasPermissions('B_salesNews')" @click="handleAdd(0)">新增(零售)</a-button>
  115. <a-button type="primary" class="button-warning" v-if="$hasPermissions('B_salesNews')" @click="handleAdd(1)">新增(铺货)</a-button>
  116. <a-checkbox style="margin-left:10px;" v-model="isByCustQuery" id="sales-byCustQuery">按客户查询</a-checkbox>
  117. <a-popover placement="right">
  118. <template slot="content">
  119. 使用此查询时,时间可清空,必须选择一个客户
  120. </template>
  121. <a-icon type="question-circle" />
  122. </a-popover>
  123. </div>
  124. <div>
  125. <a-dropdown v-model="showCell">
  126. <a-button type="link" class="button-default"> <a-icon type="setting" /> 显示</a-button>
  127. <a-menu slot="overlay">
  128. <a-menu-item>
  129. <a-checkbox v-model="showDiscount" id="salesQuery-edit-discount">折后总售价</a-checkbox>
  130. </a-menu-item>
  131. </a-menu>
  132. </a-dropdown>
  133. </div>
  134. </div>
  135. <a-alert type="info" style="margin-bottom:10px">
  136. <div slot="message">
  137. 总售价:<strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? toThousands(totalData.totalAmount) : '--' }}</strong>元;
  138. 总单数:<strong>{{ totalData&&(totalData.totalRecord || totalData.totalRecord==0) ? totalData.totalRecord : '--' }}</strong>;
  139. 总款数:<strong>{{ totalData&&(totalData.totalCategory || totalData.totalCategory==0) ? totalData.totalCategory : '--' }}</strong>;
  140. 总数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  141. </div>
  142. </a-alert>
  143. <!-- 列表 -->
  144. <s-table
  145. class="sTable fixPagination"
  146. ref="table"
  147. :style="{ height: tableHeight+77+'px' }"
  148. size="small"
  149. :rowKey="(record) => record.id"
  150. :columns="columns"
  151. :data="loadData"
  152. :scroll="{ y:tableHeight }"
  153. :defaultLoadData="false"
  154. bordered>
  155. <!-- 销售单号 -->
  156. <template slot="salesBillNo" slot-scope="text, record">
  157. <span class="table-td-link" v-if="$hasPermissions('B_salesDetail')" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  158. <span v-else>{{ record.salesBillNo }}</span>
  159. <a-badge count="改" :number-style="{ zoom:'80%',marginLeft:'5px' }" v-if="record.billStatus=='SUPERIOR_CHANGE'"></a-badge>
  160. </template>
  161. <!-- 审核 -->
  162. <template slot="audit" slot-scope="text, record">
  163. <stateIcon :title="record.billStatusDictValue" v-if="record.billStatus!='AUDIT_REJECT'" :state="record.billStatus == 'WAIT_OUT_WAREHOUSE'||record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  164. <stateIcon :title="record.billStatusDictValue" v-else :state="0"></stateIcon>
  165. </template>
  166. <!-- 急件 -->
  167. <template slot="oosFlag" slot-scope="text, record">
  168. <stateIcon :state="record.oosFlag==1?'1':'2'"></stateIcon>
  169. </template>
  170. <!-- 出库 -->
  171. <template slot="waitOut" slot-scope="text, record">
  172. <stateIcon :state="record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  173. </template>
  174. <!-- 收款 -->
  175. <template slot="financial" slot-scope="text, record">
  176. <stateIcon :title="record.financialStatusDictValue" :state="record.financialStatus == 'FINISH'?'1':'2'"></stateIcon>
  177. </template>
  178. <!-- 操作 -->
  179. <template slot="action" slot-scope="text, record">
  180. <a-button
  181. size="small"
  182. type="link"
  183. class="button-primary"
  184. v-if="record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')"
  185. @click="handleEexamine(record)"
  186. >审核</a-button>
  187. <a-button
  188. size="small"
  189. type="link"
  190. v-if="record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')"
  191. class="button-primary"
  192. @click="handleSend(record)"
  193. >出库</a-button>
  194. <a-button
  195. size="small"
  196. type="link"
  197. class="button-primary"
  198. 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')"
  199. @click="handleEdit(record)"
  200. >
  201. 编辑
  202. </a-button>
  203. <a-button
  204. size="small"
  205. type="link"
  206. class="button-error"
  207. v-if="((record.sourceType == 'SATELLITE' || record.sourceType == 'SALES' || record.sourceType == 'TEMPORARY_DISPATCHING') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel')"
  208. @click="handleDel(record)"
  209. >
  210. 删除
  211. </a-button>
  212. <a-button
  213. size="small"
  214. type="link"
  215. class="button-primary"
  216. v-if="((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesEdit')"
  217. @click="handleEdit(record)"
  218. >
  219. 改单
  220. </a-button>
  221. <a-button
  222. size="small"
  223. type="link"
  224. class="button-error"
  225. v-if="((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel')"
  226. @click="handleDel(record, 'cancel')"
  227. >
  228. 取消
  229. </a-button>
  230. <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'))">
  231. <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>
  232. </span>
  233. </template>
  234. </s-table>
  235. </a-spin>
  236. <!-- 选择客户弹框 -->
  237. <choose-custom-modal :show="openModal" :distributionFlag="distributionFlag" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  238. <!-- 审核 -->
  239. <auditModal :openModal="visibleAudit" :spinning="spinningAudit" @close="visibleAudit=false" @ok="auditOrder('WAIT_OUT_WAREHOUSE')" @fail="auditOrder('AUDIT_REJECT')" />
  240. </a-card>
  241. </template>
  242. <script>
  243. import { commonMixin } from '@/utils/mixin'
  244. import getDate from '@/libs/getDate.js'
  245. import { STable, VSelect } from '@/components'
  246. import chooseCustomModal from './chooseCustomModal.vue'
  247. import auditModal from '@/views/common/auditModal.vue'
  248. import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount, salesExport } from '@/api/sales'
  249. import rangeDate from '@/views/common/rangeDate.vue'
  250. import custList from '@/views/common/custList.vue'
  251. import { downloadExcel } from '@/libs/JGPrint.js'
  252. import stateIcon from '@/views/common/stateIcon'
  253. import moment from 'moment'
  254. export default {
  255. name: 'SalesList',
  256. components: { STable, VSelect, chooseCustomModal, rangeDate, auditModal, custList, stateIcon },
  257. mixins: [commonMixin],
  258. data () {
  259. const _this = this
  260. return {
  261. spinning: false,
  262. tableHeight: 0,
  263. advanced: true, // 高级搜索 展开/关闭
  264. disabled: false, // 查询、重置按钮是否可操作
  265. exportLoading: false, // 导出loading
  266. openModal: false, // 选择客户弹框是否显示
  267. isByCustQuery: false, // 是否按客户查询
  268. showDiscount: false,
  269. showCell: false,
  270. time: [
  271. getDate.getMonthDays(3).starttime,
  272. getDate.getMonthDays(3).endtime
  273. ],
  274. auditTime: [],
  275. outWareTime: [],
  276. // 查询参数
  277. queryParam: {
  278. beginDate: getDate.getMonthDays(3).starttime,
  279. endDate: getDate.getMonthDays(3).endtime,
  280. auditBeginDate: '',
  281. auditEndDate: '',
  282. outWarehouseBeginDate: '',
  283. outWarehouseEndDate: '',
  284. buyerNameCurrent: undefined, // 客户名称
  285. buyerSn: undefined,
  286. salesBillNo: '', // 销售单号
  287. purchaseBillNo: '', // 采购单号
  288. payType: undefined, // 支付方式
  289. settleStyleSn: undefined, // 收款方式
  290. billStatus: undefined, // 业务状态
  291. financialStatus: undefined, // 财务状态
  292. sourceType: undefined,
  293. distributionFlag: undefined
  294. },
  295. totalData: {
  296. totalAmount: 0,
  297. totalCategory: 0,
  298. totalQty: 0,
  299. totalRecord: 0
  300. },
  301. selType: '0', // 0零售 1铺货
  302. // 加载数据方法 必须为 Promise 对象
  303. loadData: parameter => {
  304. this.disabled = true
  305. this.spinning = true
  306. // 查询总计
  307. salesCount(Object.assign(parameter, this.queryParam)).then(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: 'salesDetail', params: { sn: row.salesBillSn } })
  443. },
  444. // 编辑
  445. handleEdit (row) {
  446. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  447. },
  448. // 选择客户成功
  449. chooseCustomOk (data) {
  450. this.$router.push({ name: 'salesAdd', 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 () {
  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(true)
  487. } else {
  488. if (this.queryParam.buyerSn) {
  489. this.$refs.table.refresh(true)
  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 - 265
  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(isHomeNav)
  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.$refs.rangeDate.resetDate([isHomeNav.pageParams.beginDate, isHomeNav.pageParams.endDate])
  582. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  583. this.$refs.table.refresh(true)
  584. }
  585. } else {
  586. // 如果是新页签打开,则重置当前页面
  587. if (a && !b) {
  588. this.resetSearchForm()
  589. }
  590. // 仅刷新列表,不重置页面
  591. if (b || a == b) {
  592. this.$refs.table.refresh()
  593. }
  594. }
  595. }
  596. },
  597. watch: {
  598. advanced (newValue, oldValue) {
  599. const _this = this
  600. this.$nextTick(() => { // 页面渲染完成后的回调
  601. _this.setTableH()
  602. })
  603. },
  604. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  605. this.setTableH()
  606. },
  607. isByCustQuery (newValue, oldValue) {
  608. if (!newValue) {
  609. this.resetSearchForm()
  610. }
  611. }
  612. },
  613. activated () {
  614. this.pageInit()
  615. },
  616. beforeRouteEnter (to, from, next) {
  617. next(vm => {
  618. })
  619. }
  620. }
  621. </script>