list.vue 31 KB

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