list.vue 31 KB

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