list.vue 29 KB

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