list.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  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 ref="tipModal" :openModal="openTipModal" :dataList="sourceData" @close="closeTipModal" @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, changeBillCheckUpdatePrice, changeBillCheck } 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. sourceData: [], // 改单表格数据
  351. // 默认时间
  352. time: [
  353. moment(getDate.getThreeMonthDays().starttime, 'YYYY-MM-DD'),
  354. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  355. ],
  356. // 查询参数
  357. queryParam: {
  358. beginDate: getDate.getThreeMonthDays().starttime, // 开始时间
  359. endDate: getDate.getCurrMonthDays().endtime, // 结束时间
  360. buyerSn: undefined, // 客户名称
  361. salesBillNo: '', // 销售单号
  362. purchaseBillNo: '', // 采购单号
  363. printStatus: undefined, // 打印状态
  364. billStatus: undefined, // 业务状态
  365. financialStatus: undefined, // 财务状态
  366. salesBillSource: undefined, // 单据来源
  367. subareaArea: {
  368. subareaSn: undefined, // 区域
  369. subareaAreaSn: undefined // 分区
  370. },
  371. shippingAddrProvinceSn: undefined, // 省
  372. warehouseSn: undefined, // 仓库
  373. promoFlag: undefined, // 是否促销单
  374. expenseClainFlag: undefined, // 转费用报销单状态
  375. bizUserSn: undefined // 客服
  376. },
  377. // 统计数据
  378. totalData: {
  379. totalCategory: 0, // 总款数
  380. totalQty: 0, // 总数量
  381. totalRecord: 0, // 总单数
  382. totalPushedQty: 0, // 已下推数量
  383. totalDispatchQty: 0, // 已发货数量
  384. totalCancelQty: 0, // 已取消数量
  385. totalUnpushedQty: 0, // 待下推数量
  386. totalAmount: 0, // 总售价
  387. totalPushedAmount: 0, // 已下推金额
  388. totalCancelAmount: 0, // 已取消金额
  389. totalUnpushedAmount: 0, // 待下推金额
  390. totalDispatchAmount: 0 // 已发货金额
  391. },
  392. // 加载数据方法 必须为 Promise 对象
  393. loadData: parameter => {
  394. this.disabled = true
  395. this.spinning = true
  396. delete parameter.tableId
  397. delete parameter.index
  398. // 如果按业务状态排序
  399. if (parameter.sortOrder) {
  400. parameter['sortAlias'] = 'sales_bill'
  401. } else {
  402. delete parameter.sortField
  403. }
  404. // 查询总计
  405. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  406. this.totalData = res.data || {}
  407. })
  408. // 查询列表
  409. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  410. let data
  411. if (res.status == 200) {
  412. data = res.data
  413. // 计算编号
  414. const no = (data.pageNo - 1) * data.pageSize
  415. data.list.forEach((con, i) => {
  416. con.no = no + i + 1
  417. })
  418. this.disabled = false
  419. }
  420. this.spinning = false
  421. return data
  422. })
  423. },
  424. // 允许备货打印弹框
  425. tipData: null, // 备货单信息
  426. tempSalesBillSn: null, // 关联的下推单sn
  427. selectedRowKeys: [], // 允许备货打印选项
  428. bhColumns: [
  429. {
  430. title: '备货单号',
  431. dataIndex: 'dispatchBillNo'
  432. },
  433. {
  434. title: '客户名称',
  435. dataIndex: 'buyerName'
  436. },
  437. {
  438. title: '备货打印状态',
  439. dataIndex: 'printStatusDictValue'
  440. }
  441. ],
  442. // 列表列显示
  443. showCols: [], // 已勾选的列
  444. colsArr: [
  445. {
  446. title: '已取消数量',
  447. value: 'totalCancelQty',
  448. key: 'totalCancelQty',
  449. disabled: false
  450. },
  451. {
  452. title: '待下推数量',
  453. value: 'totalUnpushedQty',
  454. key: 'totalUnpushedQty',
  455. disabled: false
  456. },
  457. {
  458. title: '待下推金额',
  459. value: 'totalUnpushedAmount',
  460. key: 'totalUnpushedAmount',
  461. disabled: !this.$hasPermissions('M_salesQueryList_salesPrice')
  462. },
  463. {
  464. title: '转采购额数量',
  465. value: 'totalConvertPromoGiftsQty',
  466. key: 'totalConvertPromoGiftsQty',
  467. disabled: false
  468. },
  469. {
  470. title: '转采购额金额',
  471. value: 'totalConvertPromoGiftsAmount',
  472. key: 'totalConvertPromoGiftsAmount',
  473. disabled: !this.$hasPermissions('M_salesQueryList_salesPrice')
  474. }
  475. ]
  476. }
  477. },
  478. computed: {
  479. columns () {
  480. const _this = this
  481. const arr = [
  482. { title: '创建时间', dataIndex: 'createDate', width: '6%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  483. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: '8%', align: 'center' },
  484. { 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 },
  485. { title: '客户名称', dataIndex: 'buyerName', width: '8%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  486. { title: '出库仓库', scopedSlots: { customRender: 'warehouseBox' }, width: '7%', align: 'center', ellipsis: true },
  487. { title: '总数量', dataIndex: 'totalQty', scopedSlots: { customRender: 'totalQty' }, width: '4%', align: 'center' },
  488. { title: '总售价', dataIndex: 'totalAmount', width: '4%', align: 'right', isShow: false, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  489. { title: '已下推数量', dataIndex: 'totalPushedQty', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  490. { title: '下推总金额', dataIndex: 'totalPushedAmount', width: '4%', align: 'right', isShow: false, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  491. { title: '待下推数量', dataIndex: 'totalUnpushedQty', width: '4%', align: 'center', isShow: false, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  492. { title: '待下推金额', dataIndex: 'totalUnpushedAmount', width: '4%', align: 'right', isShow: false, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  493. { title: '已发货数量', dataIndex: 'totalDispatchQty', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  494. { title: '已取消数量', dataIndex: 'totalCancelQty', width: '4%', align: 'center', isShow: false, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  495. { title: '转采购额数量', dataIndex: 'totalConvertPromoGiftsQty', width: '4%', align: 'center', isShow: false, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  496. { title: '转采购额金额', dataIndex: 'totalConvertPromoGiftsAmount', width: '4%', align: 'right', isShow: false, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  497. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  498. { title: '审核时间', dataIndex: 'auditDate', width: '6%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  499. { title: '最近备货时间', dataIndex: 'lastStockUpDate', width: '6%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  500. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  501. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  502. { title: '备货打印状态', dataIndex: 'printStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  503. { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
  504. ]
  505. // 根据权限及勾选按固定顺序动态显示列
  506. arr.map(item => {
  507. if (this.$hasPermissions('M_salesQueryList_salesPrice')) {
  508. item.isShow = ['totalAmount', 'totalPushedAmount', 'totalUnpushedAmount', 'totalConvertPromoGiftsAmount'].includes(item.dataIndex)
  509. }
  510. if (this.colsArr.find(k => k.value == item.dataIndex)) {
  511. item.isShow = this.showCols.includes(item.dataIndex)
  512. }
  513. })
  514. return arr.filter(item => !this.colsArr.find(k => k.value == item.dataIndex) || item.isShow)
  515. }
  516. },
  517. methods: {
  518. // 导出
  519. handleExport () {
  520. const _this = this
  521. _this.$store.state.app.curActionPermission = 'B_sales_export'
  522. _this.exportLoading = true
  523. _this.spinning = true
  524. hdExportExcel(salesDetailExport, _this.queryParam, '销售明细', function () {
  525. _this.exportLoading = false
  526. _this.spinning = false
  527. _this.showExport = true
  528. _this.$store.state.app.curActionPermission = ''
  529. })
  530. },
  531. // 选择时间 change
  532. dateChange (date) {
  533. this.queryParam.beginDate = date[0]
  534. this.queryParam.endDate = date[1]
  535. },
  536. // 选择客户
  537. custChange (val) {
  538. this.queryParam.buyerSn = val.key
  539. },
  540. // 所在区域
  541. subareaChange (val) {
  542. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  543. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  544. },
  545. // 打开批量转费用单页面
  546. toWaitCostOrder () {
  547. this.$router.push({ name: 'waitCostOrder' })
  548. },
  549. // 新增销售单先打开选择客户弹框
  550. handleAdd () {
  551. this.openModal = true
  552. },
  553. // 选择客户成功
  554. chooseCustomOk (data) {
  555. this.$router.push({ name: 'salesNewAdd', params: { sn: data.salesBillSn } })
  556. },
  557. // 下推
  558. handleDispatch (row) {
  559. this.$router.push({ name: 'waitDispatchNew', params: { salesBillSn: row.salesBillSn } })
  560. },
  561. // 详情
  562. handleDetail (row) {
  563. this.$router.push({ name: 'salesNewDetail', params: { sn: row.salesBillSn } })
  564. },
  565. // 审核
  566. handleDetailAudit (row) {
  567. this.$router.push({ name: 'salesNewDetailAudit', params: { sn: row.salesBillSn } })
  568. },
  569. // 编辑
  570. handleEdit (row) {
  571. this.$router.push({ name: 'salesNewEdit', params: { sn: row.salesBillSn } })
  572. },
  573. // 改单
  574. handleChangeOrder (row) {
  575. const _this = this
  576. _this.tempSalesBillSn = row.salesBillSn
  577. changeBillCheck({ salesBillSn: row.salesBillSn }).then(res => {
  578. let data
  579. if (res.status == 200) {
  580. data = res.data
  581. if (data && data.length > 0) {
  582. _this.sourceData = res.data
  583. const obj = {
  584. buyerName: row.buyerName,
  585. salesBillNo: row.salesBillNo
  586. }
  587. _this.$refs.tipModal.getShowInfo(obj)
  588. _this.openTipModal = true
  589. } else {
  590. _this.$router.push({ name: 'salesNewEdit', params: { sn: row.salesBillSn } })
  591. }
  592. }
  593. })
  594. },
  595. // 改单成功 关闭弹窗
  596. openTipModalOk (ajaxData) {
  597. ajaxData.salesBillSn = this.tempSalesBillSn
  598. ajaxData.detailList = this.sourceData
  599. changeBillCheckUpdatePrice(ajaxData).then(res => {
  600. if (res.status == 200) {
  601. this.$message.success(res.message)
  602. this.openTipModal = false
  603. this.$nextTick(() => {
  604. this.$router.push({ name: 'salesNewEdit', params: { sn: this.tempSalesBillSn } })
  605. })
  606. }
  607. })
  608. },
  609. // 取消时,跳转编辑页面
  610. closeTipModal () {
  611. this.openTipModal = false
  612. this.$router.push({ name: 'salesNewEdit', params: { sn: this.tempSalesBillSn } })
  613. this.$nextTick(() => {
  614. this.tempSalesBillSn = null
  615. })
  616. },
  617. // 删除
  618. handleDel (row) {
  619. const _this = this
  620. this.$confirm({
  621. title: '提示',
  622. content: row.salesBillSource == 'PURCHASE' ? '确认要取消吗?' : '确认要删除吗?',
  623. centered: true,
  624. closable: true,
  625. onOk () {
  626. _this.spinning = true
  627. const fun = row.salesBillSource == 'PURCHASE' ? salesCancle : salesDel
  628. fun({ salesBillSn: row.salesBillSn }).then(res => {
  629. if (res.status == 200) {
  630. _this.$message.success(res.message)
  631. _this.$refs.table.refresh()
  632. _this.spinning = false
  633. } else {
  634. _this.spinning = false
  635. }
  636. })
  637. }
  638. })
  639. },
  640. // 转费用单
  641. async handleExpense (row) {
  642. const _this = this
  643. _this.spinning = true
  644. const hasExpense = await queryCreateBySalesBillSn({ salesBillSn: row.salesBillSn }).then(res => res.data || [])
  645. const showModalFlag = []
  646. const optionsKey = [
  647. {
  648. id: 'balance',
  649. name: '采购额结余'
  650. },
  651. {
  652. id: 'exceed',
  653. name: '采购额超出'
  654. },
  655. {
  656. id: 'giftConvertAmount',
  657. name: '促销产品转采购额'
  658. }
  659. ]
  660. optionsKey.map(key => {
  661. if (hasExpense[key.id]) {
  662. showModalFlag.push(key)
  663. }
  664. })
  665. if (showModalFlag.length) {
  666. // 直接转费用单
  667. if (showModalFlag.length == 1) {
  668. _this.expenseSave(hasExpense[showModalFlag[0].id])
  669. }
  670. // 有2个以上采购额时
  671. if (showModalFlag.length > 1) {
  672. _this.$confirm({
  673. title: '转费用报销单?',
  674. centered: true,
  675. class: 'confirm-center',
  676. content: <div>
  677. <div style="padding:10px 0;text-align:center;">请选择费用报销单类型</div>
  678. <div style="padding:0 0 10px 0;text-align:center;">
  679. <aRadioGroup onChange={_this.changeDaOpt}>
  680. {showModalFlag.map(item => <aRadio key={item.id} style="height: '30px';lineHeight: '30px';padding:5px 0;" value={item.id}>{item.name}</aRadio>)}
  681. </aRadioGroup>
  682. </div>
  683. </div>,
  684. onOk () {
  685. if (_this.expenseOption) {
  686. _this.expenseSave(hasExpense[_this.expenseOption])
  687. } else {
  688. _this.$message.info('请选择费用报销单类型!')
  689. return true
  690. }
  691. },
  692. onCancel () {
  693. _this.expenseOption = null
  694. }
  695. })
  696. }
  697. }
  698. _this.spinning = false
  699. },
  700. // 选择费用报销单类型
  701. changeDaOpt (e) {
  702. this.expenseOption = e.target.value
  703. },
  704. // 转费用单确定
  705. expenseSave (data) {
  706. if (data) {
  707. this.openBaseModal = true
  708. this.$refs.expenseModal.setDetail(data, 'sales')
  709. }
  710. },
  711. // 转费用单成功
  712. expenseSaveOk (params) {
  713. expenseAccountSave(params).then(res => {
  714. if (res.status == 200) {
  715. this.$message.info(res.message)
  716. this.$refs.table.refresh()
  717. this.openBaseModal = false
  718. this.expenseOption = null
  719. this.$refs.expenseModal.spinning = false
  720. this.$router.push({ name: 'expenseReimbursementEdit', params: { sn: res.data.expenseAccountSn } })
  721. }
  722. })
  723. },
  724. // 允许备货打印
  725. handlePrint (row) {
  726. // 获取关联的下推单
  727. this.tempSalesBillSn = row.salesBillSn
  728. queryBySalesBillSn({ salesBillSn: row.salesBillSn }).then(res => {
  729. this.tipData = res.data || []
  730. this.tipData.map(item => {
  731. item.key = item.dispatchBillSn
  732. if (item.printStatus == 'UNABLE_PRINT') {
  733. this.selectedRowKeys.push(item.dispatchBillSn)
  734. }
  735. })
  736. this.showTipModal = true
  737. })
  738. },
  739. // 关闭允许备货打印弹框
  740. canselModal () {
  741. this.tipData = null
  742. this.showTipModal = false
  743. this.tempSalesBillSn = null
  744. this.selectedRowKeys = []
  745. },
  746. // 选择要备货打印的
  747. onSelectChange (selectedRowKeys) {
  748. this.selectedRowKeys = selectedRowKeys
  749. },
  750. // 确定允许备货打印
  751. updatePrintStatus () {
  752. const isOne = this.tipData.length
  753. if (isOne > 1 && this.selectedRowKeys.length == 0) {
  754. this.$message.info('请选择备货单!')
  755. return
  756. }
  757. const dispatchBillSnList = []
  758. this.tipData.map(item => {
  759. dispatchBillSnList.push(item.dispatchBillSn)
  760. })
  761. const params = {
  762. 'salesBillSn': this.tempSalesBillSn,
  763. 'dispatchBillSnList': isOne > 1 ? this.selectedRowKeys : dispatchBillSnList,
  764. 'printStatus': 'NO_PRINT'
  765. }
  766. dispatchBatchPrintStatus(params).then(res => {
  767. if (res.status == 200) {
  768. this.canselModal()
  769. this.$message.info(res.message)
  770. this.$refs.table.refresh()
  771. }
  772. })
  773. },
  774. // 重置列表
  775. resetSearchForm () {
  776. this.$refs.rangeDate.resetDate(this.time)
  777. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  778. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  779. this.$refs.dealerSubareaScopeList.resetForm()
  780. this.queryParam.buyerSn = undefined
  781. this.queryParam.salesBillNo = ''
  782. this.queryParam.purchaseBillNo = ''
  783. this.queryParam.printStatus = undefined
  784. this.queryParam.billStatus = undefined
  785. this.queryParam.financialStatus = undefined
  786. this.queryParam.salesBillSource = undefined
  787. this.queryParam.subareaArea.subareaSn = undefined
  788. this.queryParam.subareaArea.subareaAreaSn = undefined
  789. this.queryParam.shippingAddrProvinceSn = undefined
  790. this.queryParam.warehouseSn = undefined
  791. this.queryParam.promoFlag = undefined
  792. this.queryParam.expenseClainFlag = undefined
  793. this.queryParam.bizUserSn = undefined
  794. if (this.advanced) {
  795. this.$refs.subarea.clearData()
  796. }
  797. this.$refs.table.refresh(true)
  798. },
  799. // 初始化
  800. pageInit () {
  801. this.$nextTick(() => { // 页面渲染完成后的回调
  802. this.setTableH()
  803. })
  804. },
  805. // 计算表格高度
  806. setTableH () {
  807. const tableSearchH = this.$refs.tableSearch.offsetHeight
  808. this.tableHeight = window.innerHeight - tableSearchH - 260
  809. }
  810. },
  811. watch: {
  812. // 展开收起
  813. advanced (newValue, oldValue) {
  814. this.pageInit()
  815. },
  816. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  817. console.log(newValue)
  818. this.setTableH()
  819. }
  820. },
  821. mounted () {
  822. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  823. this.pageInit()
  824. this.resetSearchForm()
  825. }
  826. },
  827. activated () {
  828. // 如果是新页签打开,则重置当前页面
  829. if (this.$store.state.app.isNewTab) {
  830. this.pageInit()
  831. this.resetSearchForm()
  832. }
  833. // 仅刷新列表,不重置页面
  834. if (this.$store.state.app.updateList) {
  835. this.pageInit()
  836. this.$refs.table.refresh()
  837. }
  838. },
  839. beforeRouteEnter (to, from, next) {
  840. next(vm => {})
  841. }
  842. }
  843. </script>
  844. <style lang="less" scoped>
  845. .salesManagementList-wrap{
  846. .sTable{
  847. .badge-con-t{
  848. .ant-badge-count{
  849. transform: scale(0.8);
  850. font-size: 13px;
  851. }
  852. }
  853. .warehouse_box{
  854. width: 100%;
  855. overflow: hidden;
  856. white-space: nowrap;
  857. text-overflow: ellipsis;
  858. }
  859. }
  860. }
  861. </style>