list.vue 27 KB

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