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