list.vue 35 KB

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