list.vue 30 KB

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