list.vue 27 KB

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