list.vue 28 KB

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