list.vue 31 KB

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