list.vue 30 KB

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