list.vue 40 KB

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