list.vue 32 KB

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