list.vue 40 KB

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