list.vue 40 KB

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