list.vue 37 KB

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