list.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="创建时间">
  10. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="客户名称">
  15. <dealerSubareaScopeList ref="dealerSubareaScopeList" id="salesManagementList-buyerName" @change="custChange" />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="销售单号">
  20. <a-input id="salesManagementList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="采购单号">
  25. <a-input id="salesManagementList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="备货打印状态">
  30. <v-select
  31. v-model="queryParam.printStatus"
  32. ref="printStatus"
  33. id="salesManagementList-printStatus"
  34. code="PRINT_STATUS"
  35. placeholder="请选择打印状态"
  36. allowClear></v-select>
  37. </a-form-item>
  38. </a-col>
  39. <a-col :md="6" :sm="24">
  40. <a-form-item label="业务状态">
  41. <v-select
  42. v-model="queryParam.billStatus"
  43. ref="billStatus"
  44. id="salesManagementList-billStatus"
  45. code="SALES_BILL_STATUS"
  46. placeholder="请选择业务状态"
  47. allowClear></v-select>
  48. </a-form-item>
  49. </a-col>
  50. <a-col :md="6" :sm="24">
  51. <a-form-item label="财务状态">
  52. <v-select
  53. v-model="queryParam.financialStatus"
  54. ref="financialStatus"
  55. id="salesManagementList-financialStatus"
  56. code="FINANCIAL_RECEIVE_STATUS"
  57. placeholder="请选择财务状态"
  58. allowClear></v-select>
  59. </a-form-item>
  60. </a-col>
  61. <template v-if="advanced">
  62. <a-col :md="6" :sm="24">
  63. <a-form-item label="单据来源">
  64. <v-select
  65. v-model="queryParam.salesBillSource"
  66. ref="salesBillSource"
  67. id="salesManagementList-salesBillSource"
  68. code="SALES_SOURCE"
  69. placeholder="请选择单据来源"
  70. allowClear></v-select>
  71. </a-form-item>
  72. </a-col>
  73. <a-col :md="6" :sm="24">
  74. <a-form-item label="所在区域">
  75. <subarea ref="subarea" id="salesManagementList-subarea" @change="subareaChange"></subarea>
  76. </a-form-item>
  77. </a-col>
  78. <a-col :md="6" :sm="24">
  79. <a-form-item label="地区" prop="shippingAddrProvinceSn">
  80. <Area id="salesManagementList-shippingAddrProvinceSn" v-model="queryParam.shippingAddrProvinceSn" placeholder="请选择省"></Area>
  81. </a-form-item>
  82. </a-col>
  83. <a-col :md="6" :sm="24">
  84. <a-form-item label="出库仓库">
  85. <chooseWarehouse ref="warehouse" v-model="queryParam.warehouseSn"></chooseWarehouse>
  86. </a-form-item>
  87. </a-col>
  88. <a-col :md="6" :sm="24">
  89. <a-form-item label="促销单">
  90. <v-select
  91. v-model="queryParam.promoFlag"
  92. ref="cxFlag"
  93. code="FLAG"
  94. placeholder="请选择是否促销单"
  95. allowClear></v-select>
  96. </a-form-item>
  97. </a-col>
  98. <a-col :md="6" :sm="24">
  99. <a-form-item label="发货经销商">
  100. <custList id="salesManagementList-transferDealerSn" :dataAuthFlag="0" placeholder="请输入发货经销商" ref="dealerTireScopeList" @change="custTireChange" />
  101. </a-form-item>
  102. </a-col>
  103. <a-col :md="6" :sm="24">
  104. <a-form-item label="转费用报销单">
  105. <a-select v-model="queryParam.expenseClainFlag" placeholder="请选择转费用报销单状态" allowClear>
  106. <a-select-option value="N">待转</a-select-option>
  107. <a-select-option value="Y">已转</a-select-option>
  108. <a-select-option value="ALL">全部</a-select-option>
  109. </a-select>
  110. </a-form-item>
  111. </a-col>
  112. <a-col :md="6" :sm="24" v-show="isShowCustomerSearch">
  113. <a-form-item label="客服">
  114. <customerService ref="customerName" v-model="queryParam.bizUserSn"></customerService>
  115. </a-form-item>
  116. </a-col>
  117. </template>
  118. <a-col :md="6" :sm="24">
  119. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  120. <a-button style="margin-left: 10px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  121. <a-button
  122. style="margin-left: 10px"
  123. type="primary"
  124. class="button-warning"
  125. @click="handleExport"
  126. :disabled="disabled"
  127. :loading="exportLoading"
  128. v-if="$hasPermissions('B_sales_export')"
  129. >导出</a-button>
  130. <a @click="advanced=!advanced" style="margin-left: 8px">
  131. {{ advanced ? '收起' : '展开' }}
  132. <a-icon :type="advanced ? 'up' : 'down'"/>
  133. </a>
  134. </a-col>
  135. </a-row>
  136. </a-form>
  137. </div>
  138. </a-card>
  139. <a-card size="small" :bordered="false" class="salesManagementList-wrap">
  140. <a-spin :spinning="spinning" tip="Loading...">
  141. <!-- 操作按钮 -->
  142. <div class="table-operator" style="display: flex;justify-content: space-between;align-items: center;">
  143. <div style="padding-right: 15px;">
  144. <a-button type="primary" v-if="$hasPermissions('B_salesAdd')" @click="handleAdd">新增</a-button>
  145. <a-button type="primary" class="button-info" v-if="$hasPermissions('B_convertExpense')" @click="toWaitCostOrder">批量转</a-button>
  146. </div>
  147. <div style="flex-grow: 1;display: flex;justify-content: space-between;align-items: center;">
  148. <div class="tongji-bar">
  149. <div>
  150. 总单数:<strong>{{ totalData&&(totalData.totalRecord || totalData.totalRecord==0) ? totalData.totalRecord : '--' }}</strong>;
  151. 总款数:<strong>{{ totalData&&totalData.totalCategory || totalData.totalCategory == 0 ? totalData.totalCategory : '--' }}</strong>;
  152. 总数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  153. 已下推数量:<strong>{{ totalData&&(totalData.totalPushedQty || totalData.totalPushedQty==0) ? totalData.totalPushedQty : '--' }}</strong>;
  154. 已发货数量:<strong>{{ totalData&&(totalData.totalDispatchQty || totalData.totalDispatchQty==0) ? totalData.totalDispatchQty : '--' }}</strong>;
  155. 已取消数量:<strong>{{ totalData&&(totalData.totalCancelQty || totalData.totalCancelQty==0) ? totalData.totalCancelQty : '--' }}</strong>;
  156. 待下推数量:<strong>{{ totalData&&(totalData.totalUnpushedQty || totalData.totalUnpushedQty==0) ? totalData.totalUnpushedQty : '--' }}</strong>;
  157. </div>
  158. <div v-if="$hasPermissions('M_salesQueryList_salesPrice')">
  159. 总售价:<strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? toThousands(totalData.totalAmount) : '--' }}</strong>;
  160. 已下推金额:<strong>{{ totalData&&(totalData.totalPushedAmount || totalData.totalPushedAmount==0) ? toThousands(totalData.totalPushedAmount) : '--' }}</strong>;
  161. 已取消金额:<strong>{{ totalData&&(totalData.totalCancelAmount || totalData.totalCancelAmount==0) ? toThousands(totalData.totalCancelAmount) : '--' }}</strong>;
  162. 待下推金额:<strong>{{ totalData&&(totalData.totalUnpushedAmount || totalData.totalUnpushedAmount==0) ? toThousands(totalData.totalUnpushedAmount) : '--' }}</strong>;
  163. 已发货金额:<strong>{{ totalData&&(totalData.totalDispatchAmount || totalData.totalDispatchAmount==0) ? toThousands(totalData.totalDispatchAmount) : '--' }}</strong>;
  164. </div>
  165. </div>
  166. <div>
  167. <hideCellMenus :defHiddenKes="colsArr" v-model="showCols"></hideCellMenus>
  168. </div>
  169. </div>
  170. </div>
  171. <!-- 列表 -->
  172. <v-table
  173. class="sTable fixPagination"
  174. ref="table"
  175. :style="{ height: tableHeight+35+'px' }"
  176. :pagination="{pageSize:20}"
  177. :columns="columns"
  178. :data="loadData"
  179. :scroll="{ y: tableHeight }"
  180. :defaultLoadData="false"
  181. bordered>
  182. <!-- 时间表头 -->
  183. <template slot="customDateTitle">
  184. <a-tooltip placement="top" title="第一次提交时间">提交时间&nbsp;<a-icon type="question-circle" /></a-tooltip>
  185. </template>
  186. <!-- 销售单号 -->
  187. <template slot="salesBillNo" slot-scope="text, record">
  188. <span v-if="$hasPermissions('B_salesDetail')" class="link-bule" @click="handleDetail(record,'salesNewDetail')">{{ record.salesBillNo }}</span>
  189. <span v-else>{{ record.salesBillNo }}</span>
  190. <a-badge :count="'改'+record.changeTimes" :number-style="{ zoom:'0.8' }" v-if="record.changeTimes>0"></a-badge>
  191. <a-badge count="促" v-if="record.promoFlag==1" :number-style="{ backgroundColor: '#52c41a', zoom:'0.8' }"></a-badge>
  192. <a-badge count="转" v-if="record.transferFlag==1" :number-style="{ backgroundColor: '#ccb01e', zoom:'0.8' }"></a-badge>
  193. </template>
  194. <!-- 出库仓库 -->
  195. <template slot="warehouseBox" slot-scope="text, record">
  196. <a-tooltip placement="right" v-if="record.warehouseNameSet && record.warehouseNameSet.length>0">
  197. <template slot="title">
  198. <span>{{ record.warehouseNameSet.toString() }}</span>
  199. </template>
  200. <div class="warehouse_box">
  201. <span>{{ record.warehouseNameSet.toString() }}</span>
  202. </div>
  203. </a-tooltip>
  204. <div v-else>--</div>
  205. </template>
  206. <!-- 操作 -->
  207. <template slot="action" slot-scope="text, record">
  208. <div>
  209. <a-button
  210. size="small"
  211. type="link"
  212. class="button-warning"
  213. v-if="(record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_AUDIT_REJECT' || record.billStatus == 'TRANSFER_AUDIT_REJECT')&&$hasPermissions('B_salesAudit')"
  214. @click="handleDetail(record,'salesNewDetailAudit')"
  215. >审核</a-button>
  216. <a-button
  217. size="small"
  218. type="link"
  219. class="button-warning"
  220. v-if="record.billStatus == 'WAIT_PUSH'&&$hasPermissions('B_salesDispatch')"
  221. @click="handleDispatch(record)"
  222. >下推</a-button>
  223. <a-button
  224. size="small"
  225. type="link"
  226. class="button-info"
  227. v-if="(record.salesBillSource == 'SALES' && (record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'AUDIT_REJECT' || record.billStatus == 'HQ_CHANGE'))&&$hasPermissions('B_salesEdit')"
  228. @click="handleEdit(record)"
  229. >
  230. 编辑
  231. </a-button>
  232. <a-button
  233. size="small"
  234. type="link"
  235. class="button-info"
  236. v-if="record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'HQ_CHANGE' || record.billStatus == 'SUPERIOR_AUDIT_REJECT' || record.billStatus == 'TRANSFER_AUDIT_REJECT') && $hasPermissions('B_salesEdit')"
  237. @click="handleChangeOrder(record)"
  238. >
  239. 改单
  240. </a-button>
  241. <!-- 转单显示条件: 业务状态 待审核;非促销单;下级提交,且产品类型是“轮胎产品”的销售单 -->
  242. <a-button
  243. size="small"
  244. type="link"
  245. class="button-success"
  246. v-if="$hasPermissions('B_salesTransfer')&&record.promoFlag!=1&&(record.billStatus == 'WAIT_AUDIT'||record.billStatus == 'SUPERIOR_AUDIT_REJECT' || record.billStatus == 'TRANSFER_AUDIT_REJECT')&&record.salesBillSource=='PURCHASE'&&record.orderType==='TIRE'"
  247. @click="handleDetail(record,'salesNewDetailTransfer')"
  248. >
  249. 转单
  250. </a-button>
  251. <!-- 上级审核 -->
  252. <a-button
  253. size="small"
  254. type="link"
  255. class="button-info"
  256. v-if="$hasPermissions('B_higherLevelAudit')&&record.billStatus == 'SUPERIOR_WAIT_AUDIT'"
  257. @click="handleDetail(record,'salesNewDetailTransfer')"
  258. >
  259. 上级审核
  260. </a-button>
  261. <a-button
  262. size="small"
  263. type="link"
  264. class="button-error"
  265. v-if="(record.salesBillSource == 'SALES' && (record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'AUDIT_REJECT' || record.billStatus == 'HQ_CHANGE'))&&$hasPermissions('B_salesDel')"
  266. @click="handleDel(record)"
  267. >
  268. 删除
  269. </a-button>
  270. <a-button
  271. size="small"
  272. type="link"
  273. class="button-error"
  274. v-if="record.salesBillSource == 'PURCHASE' && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'HQ_CHANGE'||record.billStatus == 'SUPERIOR_AUDIT_REJECT' || record.billStatus == 'TRANSFER_AUDIT_REJECT') && $hasPermissions('B_salesDel')"
  275. @click="handleDel(record)"
  276. >
  277. 取消
  278. </a-button>
  279. <a-button
  280. size="small"
  281. type="link"
  282. class="button-warning"
  283. v-if="record.printStatus=='UNABLE_PRINT'&&$hasPermissions('B_Sales_UNABLE_PRINT')"
  284. @click="handlePrint(record)"
  285. >允许备货打印</a-button>
  286. <a-button
  287. size="small"
  288. type="link"
  289. class="button-warning"
  290. v-if="record.billStatus=='FINISH' &&(record.expenseClainFlag == 'N' ||record.expenseClainFlag == 'M' )&&$hasPermissions('B_convertExpense')"
  291. @click="handleExpense(record)"
  292. >转费用报销单</a-button>
  293. </div>
  294. </template>
  295. </v-table>
  296. </a-spin>
  297. <!-- 选择客户弹框 -->
  298. <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  299. <!-- 操作提示 -->
  300. <commonModal modalTit="操作提示" :width="this.tipData&&this.tipData.length == 1?'500px':'800px'" :openModal="showTipModal" @cancel="canselModal" @ok="updatePrintStatus">
  301. <div style="text-align: center;" v-if="this.tipData&&this.tipData.length">
  302. <div style="margin-bottom: 15px;font-size: 14px;"><strong>确认允许此单进行备货打印吗?</strong></div>
  303. <div style="line-height: 24px;" v-if="this.tipData.length == 1">
  304. <div>备货单号:{{ tipData[0]&&tipData[0].dispatchBillNo }}</div>
  305. <div>客户名称:{{ tipData[0]&&tipData[0].buyerName }}</div>
  306. </div>
  307. <div v-else>
  308. <a-table
  309. :row-selection="{ selectedRowKeys: selectedRowKeys,onChange: onSelectChange, getCheckboxProps: record => ({ props: { disabled: record.printStatus!=='UNABLE_PRINT' }})}"
  310. :columns="bhColumns"
  311. :data-source="tipData"
  312. :pagination="false"
  313. />
  314. </div>
  315. </div>
  316. </commonModal>
  317. <!-- 新增费用单 -->
  318. <baseDataModal ref="expenseModal" @expenseSaveOk="expenseSaveOk" :show="openBaseModal" @close="openBaseModal=false"></baseDataModal>
  319. <!-- 导出提示框 -->
  320. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  321. <!-- 改单 -->
  322. <tipModal ref="tipModal" :openModal="openTipModal" :dataList="sourceData" @close="closeTipModal" @ok="openTipModalOk"></tipModal>
  323. </a-card>
  324. </div>
  325. </template>
  326. <script>
  327. import moment from 'moment'
  328. import { commonMixin } from '@/utils/mixin'
  329. import getDate from '@/libs/getDate.js'
  330. import { hdExportExcel } from '@/libs/exportExcel'
  331. // 组件
  332. import subarea from '@/views/common/subarea.js'
  333. import Area from '@/views/common/area.js'
  334. import rangeDate from '@/views/common/rangeDate.vue'
  335. import { VTable, VSelect } from '@/components'
  336. import commonModal from '@/views/common/commonModal.vue'
  337. import chooseCustomModal from './chooseCustomModal.vue'
  338. import tipModal from './tipModal.vue'
  339. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  340. import baseDataModal from '@/views/expenseManagement/expenseReimbursement/baseDataModal.vue'
  341. import reportModal from '@/views/common/reportModal.vue'
  342. import chooseWarehouse from '@/views/common/chooseWarehouse'
  343. import customerService from '@/views/common/customerService'
  344. import hideCellMenus from '@/views/common/hideCellMenus'
  345. import custList from '@/views/common/custList.vue'
  346. // 接口
  347. import { dispatchBatchPrintStatus, queryBySalesBillSn } from '@/api/dispatch'
  348. import { salesList, salesDel, salesCancle, salesCount, queryCreateBySalesBillSn, expenseAccountSave, changeBillCheckUpdatePrice, changeBillCheck } from '@/api/salesNew'
  349. import { salesDetailExport } from '@/api/salesBillReport'
  350. export default {
  351. name: 'SalesQueryList',
  352. mixins: [commonMixin],
  353. components: { VTable, VSelect, tipModal, custList, hideCellMenus, chooseCustomModal, dealerSubareaScopeList, Area, rangeDate, subarea, commonModal, reportModal, chooseWarehouse, baseDataModal, customerService },
  354. data () {
  355. return {
  356. spinning: false,
  357. advanced: true, // 高级搜索 展开/关闭
  358. disabled: false, // 查询、重置按钮是否可操作
  359. openModal: false, // 选择客户弹框是否显示
  360. openBaseModal: false, // 费用弹框
  361. showTipModal: false, // 备货打印弹框
  362. showExport: false, // 导出提示框
  363. exportLoading: false, // 导出按钮加载状态
  364. expenseOption: false, // 已选转费用报销单状态
  365. tableHeight: 0, // 表格高度
  366. openTipModal: false, // 改单提示弹窗
  367. sourceData: [], // 改单表格数据
  368. // 默认时间
  369. time: [
  370. moment(getDate.getThreeMonthDays().starttime, 'YYYY-MM-DD'),
  371. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  372. ],
  373. // 查询参数
  374. queryParam: {
  375. beginDate: getDate.getThreeMonthDays().starttime, // 开始时间
  376. endDate: getDate.getCurrMonthDays().endtime, // 结束时间
  377. buyerSn: undefined, // 客户名称
  378. salesBillNo: '', // 销售单号
  379. purchaseBillNo: '', // 采购单号
  380. printStatus: undefined, // 打印状态
  381. billStatus: undefined, // 业务状态
  382. financialStatus: undefined, // 财务状态
  383. salesBillSource: undefined, // 单据来源
  384. subareaArea: {
  385. subareaSn: undefined, // 区域
  386. subareaAreaSn: undefined // 分区
  387. },
  388. shippingAddrProvinceSn: undefined, // 省
  389. warehouseSn: undefined, // 仓库
  390. promoFlag: undefined, // 是否促销单
  391. expenseClainFlag: undefined, // 转费用报销单状态
  392. bizUserSn: undefined, // 客服
  393. transferDealerSn: undefined// 发货经销商
  394. },
  395. // 统计数据
  396. totalData: {
  397. totalCategory: 0, // 总款数
  398. totalQty: 0, // 总数量
  399. totalRecord: 0, // 总单数
  400. totalPushedQty: 0, // 已下推数量
  401. totalDispatchQty: 0, // 已发货数量
  402. totalCancelQty: 0, // 已取消数量
  403. totalUnpushedQty: 0, // 待下推数量
  404. totalAmount: 0, // 总售价
  405. totalPushedAmount: 0, // 已下推金额
  406. totalCancelAmount: 0, // 已取消金额
  407. totalUnpushedAmount: 0, // 待下推金额
  408. totalDispatchAmount: 0 // 已发货金额
  409. },
  410. // 加载数据方法 必须为 Promise 对象
  411. loadData: parameter => {
  412. this.disabled = true
  413. this.spinning = true
  414. delete parameter.tableId
  415. delete parameter.index
  416. // 如果按业务状态排序
  417. if (parameter.sortOrder) {
  418. parameter['sortAlias'] = 'sales_bill'
  419. } else {
  420. delete parameter.sortField
  421. }
  422. // 查询总计
  423. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  424. this.totalData = res.data || {}
  425. })
  426. // 查询列表
  427. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  428. let data
  429. if (res.status == 200) {
  430. data = res.data
  431. // 计算编号
  432. const no = (data.pageNo - 1) * data.pageSize
  433. data.list.forEach((con, i) => {
  434. con.no = no + i + 1
  435. })
  436. this.disabled = false
  437. }
  438. this.spinning = false
  439. return data
  440. })
  441. },
  442. // 允许备货打印弹框
  443. tipData: null, // 备货单信息
  444. tempSalesBillSn: null, // 关联的下推单sn
  445. selectedRowKeys: [], // 允许备货打印选项
  446. bhColumns: [
  447. {
  448. title: '备货单号',
  449. dataIndex: 'dispatchBillNo'
  450. },
  451. {
  452. title: '客户名称',
  453. dataIndex: 'buyerName'
  454. },
  455. {
  456. title: '备货打印状态',
  457. dataIndex: 'printStatusDictValue'
  458. }
  459. ],
  460. // 列表列显示
  461. showCols: [], // 已勾选的列
  462. colsArr: [
  463. {
  464. title: '已取消数量',
  465. key: 'totalCancelQty',
  466. disabled: false,
  467. checked: false
  468. },
  469. {
  470. title: '待下推数量',
  471. key: 'totalUnpushedQty',
  472. disabled: false,
  473. checked: false
  474. },
  475. {
  476. title: '待下推金额',
  477. key: 'totalUnpushedAmount',
  478. disabled: !this.$hasPermissions('M_salesQueryList_salesPrice')
  479. },
  480. {
  481. title: '转采购额数量',
  482. key: 'totalConvertPromoGiftsQty',
  483. disabled: false,
  484. checked: false
  485. },
  486. {
  487. title: '转采购额金额',
  488. key: 'totalConvertPromoGiftsAmount',
  489. disabled: !this.$hasPermissions('M_salesQueryList_salesPrice'),
  490. checked: false
  491. }
  492. ]
  493. }
  494. },
  495. computed: {
  496. columns () {
  497. const _this = this
  498. const formatDate = function (text) {
  499. if (text) {
  500. const ret = text.split(' ')
  501. return (<div>{ret[0]}<br/>{ret[1]}</div>)
  502. }
  503. return '--'
  504. }
  505. let arr = [
  506. { title: '创建时间', dataIndex: 'createDate', width: '6%', align: 'center', customRender: function (text) { return formatDate(text) }, sorter: true },
  507. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: '8%', align: 'left' },
  508. { title: '提交时间', slots: { title: 'customDateTitle' }, dataIndex: 'firstSubmitDate', width: '6%', align: 'center', customRender: function (text) { return formatDate(text) }, sorter: true },
  509. { title: '客户名称', dataIndex: 'buyerName', width: '10%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  510. { title: '出库仓库', scopedSlots: { customRender: 'warehouseBox' }, width: '5%', align: 'center', ellipsis: true },
  511. { title: '总数量', dataIndex: 'totalQty', width: '4%', align: 'center' },
  512. { title: '总售价', dataIndex: 'totalAmount', width: '4%', align: 'right', isShow: false, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  513. { title: '已下推数量', dataIndex: 'totalPushedQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  514. { title: '下推总金额', dataIndex: 'totalPushedAmount', width: '5%', align: 'right', isShow: false, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  515. { title: '待下推数量', dataIndex: 'totalUnpushedQty', width: '5%', align: 'center', isShow: false, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  516. { title: '待下推金额', dataIndex: 'totalUnpushedAmount', width: '5%', align: 'right', isShow: false, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  517. { title: '已发货数量', dataIndex: 'totalDispatchQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  518. { title: '已取消数量', dataIndex: 'totalCancelQty', width: '5%', align: 'center', isShow: false, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  519. { title: '转采购额数量', dataIndex: 'totalConvertPromoGiftsQty', width: '5%', align: 'center', isShow: false, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  520. { title: '转采购额金额', dataIndex: 'totalConvertPromoGiftsAmount', width: '5%', align: 'right', isShow: false, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  521. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  522. { title: '审核时间', dataIndex: 'auditDate', width: '6%', align: 'center', customRender: function (text) { return formatDate(text) }, sorter: true },
  523. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  524. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  525. { title: '最近备货时间', dataIndex: 'lastStockUpDate', width: '6.5%', align: 'center', customRender: function (text) { return formatDate(text) }, sorter: true },
  526. { title: '备货打印状态', dataIndex: 'printStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  527. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  528. ]
  529. // 根据权限及勾选按固定顺序动态显示列
  530. if (!this.$hasPermissions('M_salesQueryList_salesPrice')) {
  531. arr = arr.filter(item => !['totalAmount', 'totalPushedAmount', 'totalUnpushedAmount', 'totalConvertPromoGiftsAmount'].includes(item.dataIndex))
  532. }
  533. return arr.filter(item => !this.showCols.includes(item.dataIndex))
  534. }
  535. },
  536. methods: {
  537. // 导出
  538. handleExport () {
  539. const _this = this
  540. _this.$store.state.app.curActionPermission = 'B_sales_export'
  541. _this.exportLoading = true
  542. _this.spinning = true
  543. hdExportExcel(salesDetailExport, _this.queryParam, '销售明细', function () {
  544. _this.exportLoading = false
  545. _this.spinning = false
  546. _this.showExport = true
  547. _this.$store.state.app.curActionPermission = ''
  548. })
  549. },
  550. // 选择时间 change
  551. dateChange (date) {
  552. this.queryParam.beginDate = date[0]
  553. this.queryParam.endDate = date[1]
  554. },
  555. // 选择客户
  556. custChange (val) {
  557. this.queryParam.buyerSn = val.key
  558. },
  559. // 选择发货经销商
  560. custTireChange (val) {
  561. this.queryParam.transferDealerSn = val.key
  562. },
  563. // 所在区域
  564. subareaChange (val) {
  565. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  566. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  567. },
  568. // 打开批量转费用单页面
  569. toWaitCostOrder () {
  570. this.$router.push({ name: 'waitCostOrder' })
  571. },
  572. // 新增销售单先打开选择客户弹框
  573. handleAdd () {
  574. this.openModal = true
  575. },
  576. // 选择客户成功
  577. chooseCustomOk (data) {
  578. this.$router.push({ name: 'salesNewAdd', params: { sn: data.salesBillSn } })
  579. },
  580. // 下推
  581. handleDispatch (row) {
  582. this.$router.push({ name: 'waitDispatchNew', params: { salesBillSn: row.salesBillSn } })
  583. },
  584. // 详情 审核 转单
  585. handleDetail (row, name) {
  586. this.$router.push({ name, params: { sn: row.salesBillSn, pageType: name } })
  587. },
  588. // 编辑
  589. handleEdit (row) {
  590. this.$router.push({ name: 'salesNewEdit', params: { sn: row.salesBillSn } })
  591. },
  592. // 改单
  593. handleChangeOrder (row) {
  594. const _this = this
  595. _this.tempSalesBillSn = row.salesBillSn
  596. changeBillCheck({ salesBillSn: row.salesBillSn }).then(res => {
  597. let data
  598. if (res.status == 200) {
  599. data = res.data
  600. if (data && data.length > 0) {
  601. _this.sourceData = res.data
  602. const obj = {
  603. buyerName: row.buyerName,
  604. salesBillNo: row.salesBillNo
  605. }
  606. _this.$refs.tipModal.getShowInfo(obj)
  607. _this.openTipModal = true
  608. } else {
  609. _this.$router.push({ name: 'salesNewEdit', params: { sn: row.salesBillSn } })
  610. }
  611. }
  612. })
  613. },
  614. // 改单成功 关闭弹窗
  615. openTipModalOk (ajaxData) {
  616. ajaxData.salesBillSn = this.tempSalesBillSn
  617. ajaxData.detailList = this.sourceData
  618. changeBillCheckUpdatePrice(ajaxData).then(res => {
  619. if (res.status == 200) {
  620. this.$message.success(res.message)
  621. this.openTipModal = false
  622. this.$nextTick(() => {
  623. this.$router.push({ name: 'salesNewEdit', params: { sn: this.tempSalesBillSn } })
  624. })
  625. }
  626. })
  627. },
  628. // 取消时,跳转编辑页面
  629. closeTipModal () {
  630. this.openTipModal = false
  631. this.$router.push({ name: 'salesNewEdit', params: { sn: this.tempSalesBillSn } })
  632. this.$nextTick(() => {
  633. this.tempSalesBillSn = null
  634. })
  635. },
  636. // 删除
  637. handleDel (row) {
  638. const _this = this
  639. this.$confirm({
  640. title: '提示',
  641. content: row.salesBillSource == 'PURCHASE' ? '确认要取消吗?' : '确认要删除吗?',
  642. centered: true,
  643. closable: true,
  644. onOk () {
  645. _this.spinning = true
  646. const fun = row.salesBillSource == 'PURCHASE' ? salesCancle : salesDel
  647. fun({ salesBillSn: row.salesBillSn }).then(res => {
  648. if (res.status == 200) {
  649. _this.$message.success(res.message)
  650. _this.$refs.table.refresh()
  651. _this.spinning = false
  652. } else {
  653. _this.spinning = false
  654. }
  655. })
  656. }
  657. })
  658. },
  659. // 转费用单
  660. async handleExpense (row) {
  661. const _this = this
  662. _this.spinning = true
  663. const hasExpense = await queryCreateBySalesBillSn({ salesBillSn: row.salesBillSn }).then(res => res.data || [])
  664. const showModalFlag = []
  665. const optionsKey = [
  666. {
  667. id: 'balance',
  668. name: '采购额结余'
  669. },
  670. {
  671. id: 'exceed',
  672. name: '采购额超出'
  673. },
  674. {
  675. id: 'giftConvertAmount',
  676. name: '促销产品转采购额'
  677. }
  678. ]
  679. optionsKey.map(key => {
  680. if (hasExpense[key.id]) {
  681. showModalFlag.push(key)
  682. }
  683. })
  684. if (showModalFlag.length) {
  685. // 直接转费用单
  686. if (showModalFlag.length == 1) {
  687. _this.expenseSave(hasExpense[showModalFlag[0].id])
  688. }
  689. // 有2个以上采购额时
  690. if (showModalFlag.length > 1) {
  691. _this.$confirm({
  692. title: '转费用报销单?',
  693. centered: true,
  694. class: 'confirm-center',
  695. content: <div>
  696. <div style="padding:10px 0;text-align:center;">请选择费用报销单类型</div>
  697. <div style="padding:0 0 10px 0;text-align:center;">
  698. <aRadioGroup onChange={_this.changeDaOpt}>
  699. {showModalFlag.map(item => <aRadio key={item.id} style="height: '30px';lineHeight: '30px';padding:5px 0;" value={item.id}>{item.name}</aRadio>)}
  700. </aRadioGroup>
  701. </div>
  702. </div>,
  703. onOk () {
  704. if (_this.expenseOption) {
  705. _this.expenseSave(hasExpense[_this.expenseOption])
  706. } else {
  707. _this.$message.info('请选择费用报销单类型!')
  708. return true
  709. }
  710. },
  711. onCancel () {
  712. _this.expenseOption = null
  713. }
  714. })
  715. }
  716. }
  717. _this.spinning = false
  718. },
  719. // 选择费用报销单类型
  720. changeDaOpt (e) {
  721. this.expenseOption = e.target.value
  722. },
  723. // 转费用单确定
  724. expenseSave (data) {
  725. if (data) {
  726. this.openBaseModal = true
  727. this.$refs.expenseModal.setDetail(data, 'sales')
  728. }
  729. },
  730. // 转费用单成功
  731. expenseSaveOk (params) {
  732. expenseAccountSave(params).then(res => {
  733. if (res.status == 200) {
  734. this.$message.info(res.message)
  735. this.$refs.table.refresh()
  736. this.openBaseModal = false
  737. this.expenseOption = null
  738. this.$refs.expenseModal.spinning = false
  739. this.$router.push({ name: 'expenseReimbursementEdit', params: { sn: res.data.expenseAccountSn } })
  740. }
  741. })
  742. },
  743. // 允许备货打印
  744. handlePrint (row) {
  745. // 获取关联的下推单
  746. this.tempSalesBillSn = row.salesBillSn
  747. queryBySalesBillSn({ salesBillSn: row.salesBillSn }).then(res => {
  748. this.tipData = res.data || []
  749. this.tipData.map(item => {
  750. item.key = item.dispatchBillSn
  751. if (item.printStatus == 'UNABLE_PRINT') {
  752. this.selectedRowKeys.push(item.dispatchBillSn)
  753. }
  754. })
  755. this.showTipModal = true
  756. })
  757. },
  758. // 关闭允许备货打印弹框
  759. canselModal () {
  760. this.tipData = null
  761. this.showTipModal = false
  762. this.tempSalesBillSn = null
  763. this.selectedRowKeys = []
  764. },
  765. // 选择要备货打印的
  766. onSelectChange (selectedRowKeys) {
  767. this.selectedRowKeys = selectedRowKeys
  768. },
  769. // 确定允许备货打印
  770. updatePrintStatus () {
  771. const isOne = this.tipData.length
  772. if (isOne > 1 && this.selectedRowKeys.length == 0) {
  773. this.$message.info('请选择备货单!')
  774. return
  775. }
  776. const dispatchBillSnList = []
  777. this.tipData.map(item => {
  778. dispatchBillSnList.push(item.dispatchBillSn)
  779. })
  780. const params = {
  781. 'salesBillSn': this.tempSalesBillSn,
  782. 'dispatchBillSnList': isOne > 1 ? this.selectedRowKeys : dispatchBillSnList,
  783. 'printStatus': 'NO_PRINT'
  784. }
  785. dispatchBatchPrintStatus(params).then(res => {
  786. if (res.status == 200) {
  787. this.canselModal()
  788. this.$message.info(res.message)
  789. this.$refs.table.refresh()
  790. }
  791. })
  792. },
  793. // 重置列表
  794. resetSearchForm () {
  795. this.$refs.rangeDate.resetDate(this.time)
  796. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  797. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  798. this.$refs.dealerSubareaScopeList.resetForm()
  799. this.queryParam.buyerSn = undefined
  800. this.queryParam.salesBillNo = ''
  801. this.queryParam.purchaseBillNo = ''
  802. this.queryParam.printStatus = undefined
  803. this.queryParam.billStatus = undefined
  804. this.queryParam.financialStatus = undefined
  805. this.queryParam.salesBillSource = undefined
  806. this.queryParam.subareaArea.subareaSn = undefined
  807. this.queryParam.subareaArea.subareaAreaSn = undefined
  808. this.queryParam.shippingAddrProvinceSn = undefined
  809. this.queryParam.warehouseSn = undefined
  810. this.queryParam.promoFlag = undefined
  811. this.queryParam.expenseClainFlag = undefined
  812. this.queryParam.bizUserSn = undefined
  813. this.queryParam.transferDealerSn = undefined
  814. if (this.advanced) {
  815. this.$refs.subarea.clearData()
  816. }
  817. this.$refs.table.refresh(true)
  818. },
  819. // 初始化
  820. pageInit () {
  821. this.$nextTick(() => { // 页面渲染完成后的回调
  822. this.setTableH()
  823. })
  824. },
  825. // 计算表格高度
  826. setTableH () {
  827. const tableSearchH = this.$refs.tableSearch.offsetHeight
  828. this.tableHeight = window.innerHeight - tableSearchH - 210
  829. }
  830. },
  831. watch: {
  832. // 展开收起
  833. advanced (newValue, oldValue) {
  834. this.pageInit()
  835. },
  836. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  837. console.log(newValue)
  838. this.setTableH()
  839. }
  840. },
  841. mounted () {
  842. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  843. this.pageInit()
  844. this.resetSearchForm()
  845. }
  846. },
  847. activated () {
  848. // 如果是新页签打开,则重置当前页面
  849. if (this.$store.state.app.isNewTab) {
  850. this.pageInit()
  851. this.resetSearchForm()
  852. }
  853. // 仅刷新列表,不重置页面
  854. if (this.$store.state.app.updateList) {
  855. this.pageInit()
  856. this.$refs.table.refresh()
  857. }
  858. },
  859. beforeRouteEnter (to, from, next) {
  860. next(vm => {})
  861. }
  862. }
  863. </script>
  864. <style lang="less" scoped>
  865. .salesManagementList-wrap{
  866. .sTable{
  867. .badge-con-t{
  868. .ant-badge-count{
  869. transform: scale(0.8);
  870. font-size: 13px;
  871. }
  872. }
  873. .warehouse_box{
  874. width: 100%;
  875. overflow: hidden;
  876. white-space: nowrap;
  877. text-overflow: ellipsis;
  878. }
  879. }
  880. }
  881. </style>