list.vue 39 KB

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