list.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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" style="display:flex;align-items: center;justify-content: space-between;">
  112. <div>
  113. <a-button type="primary" class="button-error" v-if="$hasPermissions('B_salesNews')" @click="handleAdd(0)">新增(零售)</a-button>
  114. <a-button type="primary" class="button-warning" v-if="$hasPermissions('B_salesNews')" @click="handleAdd(1)">新增(铺货)</a-button>
  115. <a-checkbox style="margin-left:10px;" v-model="isByCustQuery" id="sales-byCustQuery">按客户查询</a-checkbox>
  116. <a-popover placement="right">
  117. <template slot="content">
  118. 使用此查询时,时间可清空,必须选择一个客户
  119. </template>
  120. <a-icon type="question-circle" />
  121. </a-popover>
  122. </div>
  123. <div>
  124. <a-dropdown v-model="showCell">
  125. <a-button type="link" class="button-default"> <a-icon type="setting" /> 显示</a-button>
  126. <a-menu slot="overlay">
  127. <a-menu-item>
  128. <a-checkbox v-model="showDiscount" id="salesQuery-edit-discount">折后总售价</a-checkbox>
  129. </a-menu-item>
  130. </a-menu>
  131. </a-dropdown>
  132. </div>
  133. </div>
  134. <a-alert type="info" style="margin-bottom:10px">
  135. <div slot="message">
  136. 总售价:<strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? toThousands(totalData.totalAmount) : '--' }}</strong>元;
  137. 总单数:<strong>{{ totalData&&(totalData.totalRecord || totalData.totalRecord==0) ? totalData.totalRecord : '--' }}</strong>;
  138. 总款数:<strong>{{ totalData&&(totalData.totalCategory || totalData.totalCategory==0) ? totalData.totalCategory : '--' }}</strong>;
  139. 总数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  140. </div>
  141. </a-alert>
  142. <!-- 列表 -->
  143. <s-table
  144. class="sTable fixPagination"
  145. ref="table"
  146. :style="{ height: tableHeight+77+'px' }"
  147. size="small"
  148. :rowKey="(record) => record.id"
  149. :columns="columns"
  150. :data="loadData"
  151. :scroll="{ y:tableHeight }"
  152. :defaultLoadData="false"
  153. bordered>
  154. <!-- 销售单号 -->
  155. <template slot="salesBillNo" slot-scope="text, record">
  156. <span class="table-td-link" v-if="$hasPermissions('B_salesDetail')" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  157. <span v-else>{{ record.salesBillNo }}</span>
  158. <a-badge count="改" :number-style="{ zoom:'80%',marginLeft:'5px' }" v-if="record.billStatus=='SUPERIOR_CHANGE'"></a-badge>
  159. </template>
  160. <!-- 审核 -->
  161. <template slot="audit" slot-scope="text, record">
  162. <stateIcon :title="record.billStatusDictValue" v-if="record.billStatus!='AUDIT_REJECT'" :state="record.billStatus == 'WAIT_OUT_WAREHOUSE'||record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  163. <stateIcon :title="record.billStatusDictValue" v-else :state="0"></stateIcon>
  164. </template>
  165. <!-- 急件 -->
  166. <template slot="oosFlag" slot-scope="text, record">
  167. <stateIcon :state="record.oosFlag==1?'1':'2'"></stateIcon>
  168. </template>
  169. <!-- 出库 -->
  170. <template slot="waitOut" slot-scope="text, record">
  171. <stateIcon :state="record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  172. </template>
  173. <!-- 收款 -->
  174. <template slot="financial" slot-scope="text, record">
  175. <stateIcon :title="record.financialStatusDictValue" :state="record.financialStatus == 'FINISH'?'1':'2'"></stateIcon>
  176. </template>
  177. <!-- 操作 -->
  178. <template slot="action" slot-scope="text, record">
  179. <a-button
  180. size="small"
  181. type="link"
  182. class="button-primary"
  183. v-if="record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')"
  184. @click="handleEexamine(record)"
  185. >审核</a-button>
  186. <a-button
  187. size="small"
  188. type="link"
  189. v-if="record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')"
  190. class="button-primary"
  191. @click="handleSend(record)"
  192. >出库</a-button>
  193. <a-button
  194. size="small"
  195. type="link"
  196. class="button-primary"
  197. 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')"
  198. @click="handleEdit(record)"
  199. >
  200. 编辑
  201. </a-button>
  202. <a-button
  203. size="small"
  204. type="link"
  205. class="button-error"
  206. v-if="((record.sourceType == 'SATELLITE' || record.sourceType == 'SALES' || record.sourceType == 'TEMPORARY_DISPATCHING') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel')"
  207. @click="handleDel(record)"
  208. >
  209. 删除
  210. </a-button>
  211. <a-button
  212. size="small"
  213. type="link"
  214. class="button-primary"
  215. v-if="((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesEdit')"
  216. @click="handleEdit(record)"
  217. >
  218. 改单
  219. </a-button>
  220. <a-button
  221. size="small"
  222. type="link"
  223. class="button-error"
  224. v-if="((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel')"
  225. @click="handleDel(record, 'cancel')"
  226. >
  227. 取消
  228. </a-button>
  229. <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'))">
  230. <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>
  231. </span>
  232. </template>
  233. </s-table>
  234. </a-spin>
  235. <!-- 选择客户弹框 -->
  236. <choose-custom-modal :show="openModal" :distributionFlag="distributionFlag" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  237. <!-- 审核 -->
  238. <auditModal :openModal="visibleAudit" :spinning="spinningAudit" @close="visibleAudit=false" @ok="auditOrder('WAIT_OUT_WAREHOUSE')" @fail="auditOrder('AUDIT_REJECT')" />
  239. </a-card>
  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(12).starttime,
  271. getDate.getMonthDays(12).endtime
  272. ],
  273. auditTime: [],
  274. outWareTime: [],
  275. // 查询参数
  276. queryParam: {
  277. beginDate: getDate.getMonthDays(12).starttime,
  278. endDate: getDate.getMonthDays(12).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. this.totalData = Object.assign(this.totalData, res.data || {})
  308. })
  309. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  310. let data
  311. if (res.status == 200) {
  312. data = res.data
  313. const no = (data.pageNo - 1) * data.pageSize
  314. for (var i = 0; i < data.list.length; i++) {
  315. data.list[i].no = no + i + 1
  316. }
  317. this.disabled = false
  318. }
  319. console.log(res, 'res')
  320. this.spinning = false
  321. return data
  322. })
  323. },
  324. visibleAudit: false,
  325. auditInfo: null,
  326. spinningAudit: false,
  327. distributionFlag: '0'
  328. }
  329. },
  330. computed: {
  331. columns () {
  332. const _this = this
  333. const arr = [
  334. { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
  335. { title: '来源', dataIndex: 'sourceTypeDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  336. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: '9%', align: 'center' },
  337. { title: '客户名称', dataIndex: 'buyerNameCurrent', align: 'center', width: '15%', customRender: function (text) { return text || '--' } },
  338. { title: '总款数', dataIndex: 'totalCategory', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  339. { title: '总数量', dataIndex: 'totalQty', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  340. { title: '总售价', dataIndex: 'totalAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  341. // { title: '折扣金额', dataIndex: 'discountAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  342. // { title: '折后总售价', dataIndex: 'discountedAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  343. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  344. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  345. { title: '审核时间', dataIndex: 'auditDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  346. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  347. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '2%', align: 'center' },
  348. { title: '急件', scopedSlots: { customRender: 'oosFlag' }, width: '2%', align: 'center' },
  349. { title: '出库', scopedSlots: { customRender: 'waitOut' }, width: '2%', align: 'center' },
  350. { title: '收款', scopedSlots: { customRender: 'financial' }, width: '2%', align: 'center' },
  351. // { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  352. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  353. ]
  354. // 显示折扣
  355. if (this.showDiscount) {
  356. arr.splice(7, 0, { title: '折扣金额', dataIndex: 'discountAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  357. arr.splice(8, 0, { title: '折后总售价', dataIndex: 'discountedAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  358. }
  359. return arr
  360. }
  361. },
  362. methods: {
  363. // 时间 change
  364. dateChange (date) {
  365. this.queryParam.beginDate = date[0]
  366. this.queryParam.endDate = date[1]
  367. },
  368. auditDateChange (date) {
  369. this.auditTime = date
  370. this.queryParam.auditBeginDate = date[0]
  371. this.queryParam.auditEndDate = date[1]
  372. },
  373. outWareDateChange (date) {
  374. this.outWareTime = date
  375. this.queryParam.outWarehouseBeginDate = date[0]
  376. this.queryParam.outWarehouseEndDate = date[1]
  377. },
  378. custChange (v, row) {
  379. console.log(v, row)
  380. if (row && row.customerSn) {
  381. this.queryParam.buyerSn = row.customerSn
  382. this.queryParam.buyerNameCurrent = undefined
  383. } else {
  384. this.queryParam.buyerNameCurrent = v
  385. this.queryParam.buyerSn = undefined
  386. }
  387. },
  388. // 新增
  389. handleAdd (flag) {
  390. this.openModal = true
  391. this.distributionFlag = flag
  392. },
  393. // 审核
  394. handleEexamine (row) {
  395. this.auditInfo = row
  396. this.visibleAudit = true
  397. },
  398. auditOrder (billStatus) {
  399. this.spinningAudit = true
  400. salesWriteAudit({
  401. id: this.auditInfo.id,
  402. billStatus: billStatus
  403. }).then(res => {
  404. if (res.status == 200) {
  405. this.visibleAudit = false
  406. this.$message.success(res.message)
  407. this.$refs.table.refresh()
  408. this.spinningAudit = false
  409. } else {
  410. this.visibleAudit = false
  411. this.spinningAudit = false
  412. }
  413. })
  414. },
  415. // 出库
  416. handleSend (row) {
  417. const _this = this
  418. this.$confirm({
  419. title: '提示',
  420. content: '确认要出库吗?',
  421. centered: true,
  422. closable: true,
  423. onOk () {
  424. _this.spinning = true
  425. salesWriteStockOut({
  426. salesBillSn: row.salesBillSn
  427. }).then(res => {
  428. if (res.status == 200) {
  429. _this.$message.success(res.message)
  430. _this.$refs.table.refresh()
  431. _this.spinning = false
  432. } else {
  433. _this.spinning = false
  434. }
  435. })
  436. }
  437. })
  438. },
  439. // 详情
  440. handleDetail (row) {
  441. this.$router.push({ name: 'salesDetail', params: { sn: row.salesBillSn } })
  442. },
  443. // 编辑
  444. handleEdit (row) {
  445. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  446. },
  447. // 选择客户成功
  448. chooseCustomOk (data) {
  449. this.$router.push({ name: 'salesAdd', params: { id: data.id, sn: data.salesBillSn, priceType: data.priceType } })
  450. },
  451. // 删除
  452. handleDel (row, type) {
  453. const _this = this
  454. let content = '确认要删除吗?'
  455. if (type == 'cancel') {
  456. content = '确认要取消吗?'
  457. }
  458. this.$confirm({
  459. title: '提示',
  460. content: <div><div style='font-size:16px;margin-bottom:10px;'>{content}</div><div>销售单号:{row.salesBillNo}</div><div>客户名称:{row.buyerNameCurrent}</div></div>,
  461. centered: true,
  462. closable: true,
  463. onOk () {
  464. _this.spinning = true
  465. salesDel({ id: row.id, mainFlag: 1 }).then(res => {
  466. if (res.status == 200) {
  467. _this.$message.success(res.message)
  468. _this.$refs.table.refresh()
  469. _this.spinning = false
  470. } else {
  471. _this.spinning = false
  472. }
  473. })
  474. }
  475. })
  476. },
  477. searchForm () {
  478. if (!this.isByCustQuery) {
  479. const a = moment(this.queryParam.beginDate)
  480. const b = moment(this.queryParam.endDate)
  481. if (b.diff(a, 'days') > 730) {
  482. this.$message.info('最多只能选择2年的时间区间')
  483. return false
  484. }
  485. this.$refs.table.refresh(true)
  486. } else {
  487. if (this.queryParam.buyerSn) {
  488. this.$refs.table.refresh(true)
  489. } else {
  490. this.$message.info('请选择客户')
  491. return false
  492. }
  493. }
  494. },
  495. // 重置
  496. resetSearchForm () {
  497. this.resetData()
  498. this.$refs.table.refresh(true)
  499. },
  500. // 重置数据
  501. resetData (flag) {
  502. this.$refs.rangeDate.resetDate(flag ? '' : this.time)
  503. this.queryParam.beginDate = flag ? '' : getDate.getMonthDays(12).starttime
  504. this.queryParam.endDate = flag ? '' : getDate.getMonthDays(12).endtime
  505. this.queryParam.auditBeginDate = ''
  506. this.queryParam.auditEndDate = ''
  507. this.queryParam.outWarehouseBeginDate = ''
  508. this.queryParam.outWarehouseEndDate = ''
  509. this.auditTime = []
  510. this.outWareTime = []
  511. if (this.advanced) {
  512. this.$refs.auditRangeDate.resetDate('')
  513. this.$refs.outWareRangeDate.resetDate('')
  514. }
  515. this.queryParam.buyerNameCurrent = undefined
  516. this.queryParam.buyerSn = undefined
  517. this.queryParam.salesBillNo = ''
  518. this.queryParam.purchaseBillNo = ''
  519. this.queryParam.payType = undefined
  520. this.queryParam.settleStyleSn = undefined
  521. this.queryParam.billStatus = undefined
  522. this.queryParam.financialStatus = undefined
  523. this.queryParam.sourceType = undefined
  524. this.queryParam.distributionFlag = undefined
  525. this.$refs.custList.resetForm()
  526. if (!flag) {
  527. this.setIsHomeNav(this.$route.name, null)
  528. }
  529. },
  530. // 导出
  531. handleExport () {
  532. const _this = this
  533. const params = this.queryParam
  534. params.showDiscountAmountFlag = this.showDiscount ? 1 : 0
  535. this.exportLoading = true
  536. _this.spinning = true
  537. salesExport(params).then(res => {
  538. this.exportLoading = false
  539. _this.spinning = false
  540. if (res.type == 'application/json') {
  541. var reader = new FileReader()
  542. reader.addEventListener('loadend', function () {
  543. const obj = JSON.parse(reader.result)
  544. _this.$notification.error({
  545. message: '提示',
  546. description: obj.message
  547. })
  548. })
  549. reader.readAsText(res)
  550. } else {
  551. downloadExcel(res, '销售列表')
  552. }
  553. })
  554. },
  555. setTableH () {
  556. const tableSearchH = this.$refs.tableSearch.offsetHeight
  557. this.tableHeight = window.innerHeight - tableSearchH - 265
  558. },
  559. pageInit () {
  560. const _this = this
  561. this.$nextTick(() => { // 页面渲染完成后的回调
  562. _this.setTableH()
  563. })
  564. // 是否打开的页签
  565. const a = this.$store.state.app.isNewTab
  566. // 是否要刷新列表
  567. const b = this.$store.state.app.updateList
  568. // 是否从首页点击进入
  569. const isHomeNav = this.getIsHomeNav()[this.$route.name]
  570. console.log(a, b)
  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.resetData(true)
  582. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  583. this.$refs.rangeDate.resetDate([this.queryParam.beginDate, this.queryParam.endDate])
  584. setTimeout(() => {
  585. this.$refs.table.refresh(true)
  586. }, 100)
  587. }
  588. } else {
  589. // 如果是新页签打开,则重置当前页面
  590. if (a && !b) {
  591. this.resetSearchForm()
  592. }
  593. }
  594. // 仅刷新列表,不重置页面
  595. if (b || a == b) {
  596. this.$refs.table.refresh()
  597. }
  598. }
  599. },
  600. watch: {
  601. advanced (newValue, oldValue) {
  602. const _this = this
  603. this.$nextTick(() => { // 页面渲染完成后的回调
  604. _this.setTableH()
  605. })
  606. },
  607. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  608. this.setTableH()
  609. },
  610. isByCustQuery (newValue, oldValue) {
  611. if (!newValue) {
  612. this.resetSearchForm()
  613. }
  614. }
  615. },
  616. activated () {
  617. this.pageInit()
  618. },
  619. beforeRouteEnter (to, from, next) {
  620. next(vm => {
  621. })
  622. }
  623. }
  624. </script>