list.vue 31 KB

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