list.vue 31 KB

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