list.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <template>
  2. <div class="jg-page-wrap salesManagementList-wrap">
  3. <a-card size="small" :bordered="false" class="table-page-search-wrapper">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch">
  6. <a-form layout="inline" @keyup.enter.native="searchForm">
  7. <a-row type="flex" justify="start" :gutter="15">
  8. <a-col :span="6">
  9. <a-form-item label="创建时间">
  10. <rangeDate
  11. id="salesManagementList-creatdate"
  12. :allowClear="isByCustQuery"
  13. :hasDisabledAreaTime="false"
  14. ref="rangeDate"
  15. :value="time"
  16. @change="dateChange" />
  17. </a-form-item>
  18. </a-col>
  19. <a-col :span="6">
  20. <a-form-item label="客户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}" :required="isByCustQuery">
  21. <custList id="salesManagementList-custList" ref="custList" @change="custChange"></custList>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :span="6" v-if="advanced">
  25. <a-form-item label="收款方式">
  26. <v-select
  27. code="SETTLE_STYLE"
  28. id="salesManagementList-settleStyleSn"
  29. v-model="queryParam.settleStyleSn"
  30. allowClear
  31. placeholder="请选择收款方式"
  32. ></v-select>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :span="6" v-if="advanced">
  36. <a-form-item label="业务状态">
  37. <v-select
  38. v-model="queryParam.billStatus"
  39. ref="billStatus"
  40. id="salesManagementList-billStatus"
  41. code="SALES_BILL_STATUS"
  42. placeholder="请选择业务状态"
  43. allowClear></v-select>
  44. </a-form-item>
  45. </a-col>
  46. <a-col :span="6">
  47. <a-form-item label="审核时间">
  48. <rangeDate id="salesManagementList-auditDate" ref="auditRangeDate" v-model="auditTime" @change="auditDateChange" />
  49. </a-form-item>
  50. </a-col>
  51. <a-col :span="6">
  52. <a-form-item label="销售单号">
  53. <a-input id="salesManagementList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  54. </a-form-item>
  55. </a-col>
  56. <a-col :span="6" v-if="advanced">
  57. <a-form-item label="单据来源">
  58. <v-select
  59. v-model="queryParam.sourceType"
  60. ref="sourceType"
  61. id="salesManagementList-sourceType"
  62. code="SALES_SOURCE"
  63. placeholder="请选择单据来源"
  64. allowClear></v-select>
  65. </a-form-item>
  66. </a-col>
  67. <a-col :span="6" v-if="advanced">
  68. <a-form-item label="财务状态">
  69. <v-select
  70. v-model="queryParam.financialStatus"
  71. ref="financialStatus"
  72. id="salesManagementList-financialStatus"
  73. code="FINANCIAL_RECEIVE_STATUS"
  74. placeholder="请选择财务状态"
  75. allowClear></v-select>
  76. </a-form-item>
  77. </a-col>
  78. <a-col :span="6" v-if="advanced">
  79. <a-form-item label="出库时间">
  80. <rangeDate id="salesManagementList-chukushijian" ref="outWareRangeDate" v-model="outWareTime" @change="outWareDateChange" />
  81. </a-form-item>
  82. </a-col>
  83. <a-col :span="6" v-if="advanced">
  84. <a-form-item label="采购单号">
  85. <a-input id="salesManagementList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
  86. </a-form-item>
  87. </a-col>
  88. <a-col :span="6" v-if="advanced">
  89. <a-form-model-item label="铺货出库">
  90. <v-select code="FLAG" id="salesManagementList-distributionFlag" v-model="queryParam.distributionFlag" allowClear placeholder="请选择是否铺货出库"></v-select>
  91. </a-form-model-item>
  92. </a-col>
  93. <a-col :span="24" style="display:flex;align-items: center;">
  94. <div style="text-align:left;width:50%;">
  95. <a-checkbox v-model="isByCustQuery" id="sales-byCustQuery">按客户查询</a-checkbox>
  96. <a-popover placement="right">
  97. <template slot="content">
  98. 使用此查询时,时间可清空,必须选择一个客户
  99. </template>
  100. <a-icon type="question-circle" />
  101. </a-popover>
  102. </div>
  103. <div style="text-align:left;margin-left: -120px;width:50%;">
  104. <a-button id="salesManagementList-search" type="primary" :disabled="disabled" @click="searchForm">查询</a-button>
  105. <a-button id="salesManagementList-reset" style="margin-left: 5px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  106. <a-button
  107. type="primary"
  108. v-if="$hasPermissions('B_salesExport')"
  109. class="button-warning"
  110. @click="handleExport"
  111. :disabled="disabled"
  112. :loading="exportLoading"
  113. id="salesManagementList-export">导出</a-button>
  114. <a @click="advanced=!advanced" style="margin-left: 5px" id="salesManagementList-advanced">
  115. {{ advanced ? '收起' : '展开' }}
  116. <a-icon :type="advanced ? 'up' : 'down'"/>
  117. </a>
  118. </div>
  119. </a-col>
  120. </a-row>
  121. </a-form>
  122. </div>
  123. </a-card>
  124. <a-card size="small" :bordered="false">
  125. <a-spin :spinning="spinning" tip="Loading...">
  126. <!-- 统计 -->
  127. <div class="table-operator" style="display:flex;align-items:center;justify-content: space-between;">
  128. <div class="alert-message">
  129. 合计:
  130. 总单数:<strong>{{ totalData&&(totalData.totalRecord || totalData.totalRecord==0) ? totalData.totalRecord : '--' }}</strong>;
  131. 总款数:<strong>{{ totalData&&(totalData.totalCategory || totalData.totalCategory==0) ? totalData.totalCategory : '--' }}</strong>;
  132. 总数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  133. 总售价:<strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? toThousands(totalData.totalAmount) : '--' }}</strong>;
  134. <span v-if="showDiscount">
  135. 折扣金额:<strong>{{ totalData&&(totalData.discountAmount || totalData.discountAmount==0) ? toThousands(totalData.discountAmount) : '--' }}</strong>;
  136. 折后总售价:<strong>{{ totalData&&(totalData.discountedAmount || totalData.discountedAmount==0) ? toThousands(totalData.discountedAmount) : '--' }}</strong>;
  137. </span>
  138. </div>
  139. <div class="action-buttons">
  140. <a-button id="salesManagementList-add0" type="primary" class="button-error" v-if="$hasPermissions('B_salesNews')" @click="handleAdd(0)"><a-icon type="plus" /> 新增(零售)</a-button>
  141. <a-button id="salesManagementList-add1" type="primary" class="button-error" v-if="$hasPermissions('B_salesNews')" @click="handleAdd(1)"><a-icon type="plus" /> 新增(铺货)</a-button>
  142. <a-dropdown v-model="showCell">
  143. <a-button type="link" class="button-default"> <a-icon type="setting" /> 显示</a-button>
  144. <a-menu slot="overlay">
  145. <a-menu-item>
  146. <a-checkbox v-model="showDiscount" id="salesManagementList-discount">折后总售价</a-checkbox>
  147. </a-menu-item>
  148. </a-menu>
  149. </a-dropdown>
  150. </div>
  151. </div>
  152. <!-- 列表 -->
  153. <s-table
  154. class="sTable fixPagination"
  155. ref="table"
  156. :style="{ height: tableHeight+84+'px' }"
  157. size="small"
  158. :rowKey="(record) => record.id"
  159. :columns="columns"
  160. :data="loadData"
  161. :scroll="{ y:tableHeight }"
  162. :defaultLoadData="false"
  163. bordered>
  164. <!-- 销售单号 -->
  165. <template slot="salesBillNo" slot-scope="text, record">
  166. <span class="table-td-link" :id="'salesManagementList-detail-'+record.id" v-if="$hasPermissions('B_salesDetail')" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  167. <span v-else>{{ record.salesBillNo }}</span>
  168. <a-badge count="改" :number-style="{ zoom:'80%',marginLeft:'5px' }" v-if="record.billStatus=='SUPERIOR_CHANGE'"></a-badge>
  169. </template>
  170. <!-- 审核 -->
  171. <template slot="audit" slot-scope="text, record">
  172. <stateIcon :title="record.billStatusDictValue" v-if="record.billStatus!='AUDIT_REJECT'" :state="record.billStatus == 'WAIT_OUT_WAREHOUSE'||record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  173. <stateIcon :title="record.billStatusDictValue" v-else :state="0"></stateIcon>
  174. </template>
  175. <!-- 急件 -->
  176. <template slot="oosFlag" slot-scope="text, record">
  177. <stateIcon :state="record.oosFlag==1?'1':'2'"></stateIcon>
  178. </template>
  179. <!-- 出库 -->
  180. <template slot="waitOut" slot-scope="text, record">
  181. <stateIcon :state="record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  182. </template>
  183. <!-- 收款 -->
  184. <template slot="financial" slot-scope="text, record">
  185. <stateIcon :title="record.financialStatusDictValue" :state="record.financialStatus == 'FINISH'?'1':'2'"></stateIcon>
  186. </template>
  187. <!-- 操作 -->
  188. <template slot="action" slot-scope="text, record">
  189. <a-button
  190. :id="'salesManagementList-audit-'+record.id"
  191. size="small"
  192. type="link"
  193. class="button-primary"
  194. v-if="record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')"
  195. @click="handleEexamine(record)"
  196. >审核</a-button>
  197. <a-button
  198. :id="'salesManagementList-outStock-'+record.id"
  199. size="small"
  200. type="link"
  201. v-if="record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')"
  202. class="button-primary"
  203. @click="handleSend(record)"
  204. >出库</a-button>
  205. <a-button
  206. :id="'salesManagementList-edit-'+record.id"
  207. size="small"
  208. type="link"
  209. class="button-primary"
  210. v-if="((record.sourceType == 'SATELLITE' || record.sourceType == 'SALES' || record.sourceType == 'TEMPORARY_DISPATCHING') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'AUDIT_REJECT')) && $hasPermissions('B_salesEdit')"
  211. @click="handleEdit(record)"
  212. >
  213. 编辑
  214. </a-button>
  215. <a-button
  216. :id="'salesManagementList-del-'+record.id"
  217. size="small"
  218. type="link"
  219. class="button-error"
  220. v-if="((record.sourceType == 'SATELLITE' || record.sourceType == 'SALES' || record.sourceType == 'TEMPORARY_DISPATCHING') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel')"
  221. @click="handleDel(record)"
  222. >
  223. 删除
  224. </a-button>
  225. <a-button
  226. :id="'salesManagementList-editUp-'+record.id"
  227. size="small"
  228. type="link"
  229. class="button-primary"
  230. v-if="((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesEdit')"
  231. @click="handleEdit(record)"
  232. >
  233. 改单
  234. </a-button>
  235. <a-button
  236. :id="'salesManagementList-cancel-'+record.id"
  237. size="small"
  238. type="link"
  239. class="button-error"
  240. v-if="((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel')"
  241. @click="handleDel(record, 'cancel')"
  242. >
  243. 取消
  244. </a-button>
  245. <span v-if="!(record.billStatus == 'WAIT_AUDIT' && $hasPermissions('B_salesAudit')) && !(record.billStatus == 'WAIT_OUT_WAREHOUSE' && $hasPermissions('B_salesStockOut')) && !(((record.sourceType == 'SATELLITE' || record.sourceType == 'SALES' || record.sourceType == 'TEMPORARY_DISPATCHING') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'WAIT_SUBMIT' || record.billStatus == 'AUDIT_REJECT')) && $hasPermissions('B_salesEdit')) && !(((record.sourceType == 'SATELLITE' || record.sourceType == 'SALES' || record.sourceType == 'TEMPORARY_DISPATCHING') && record.billStatus != 'FINISH') && $hasPermissions('B_salesDel'))">
  246. <span v-if="!(((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) &&$hasPermissions('B_salesEdit')) && !(((record.sourceType == 'CHILD_PURCHASE'||record.sourceType == 'DEALER_PURCHASE') && (record.billStatus == 'WAIT_AUDIT' || record.billStatus == 'SUPERIOR_CHANGE')) && $hasPermissions('B_salesDel'))">--</span>
  247. </span>
  248. </template>
  249. </s-table>
  250. </a-spin>
  251. <!-- 选择客户弹框 -->
  252. <choose-custom-modal :show="openModal" :distributionFlag="distributionFlag" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  253. <!-- 审核 -->
  254. <auditModal :openModal="visibleAudit" :spinning="spinningAudit" @close="visibleAudit=false" @ok="auditOrder('WAIT_OUT_WAREHOUSE')" @fail="auditOrder('AUDIT_REJECT')" />
  255. </a-card>
  256. </div>
  257. </template>
  258. <script>
  259. import { commonMixin } from '@/utils/mixin'
  260. import getDate from '@/libs/getDate.js'
  261. import { STable, VSelect } from '@/components'
  262. import chooseCustomModal from './chooseCustomModal.vue'
  263. import auditModal from '@/views/common/auditModal.vue'
  264. import rangeDate from '@/views/common/rangeDate.vue'
  265. import custList from '@/views/common/custList.vue'
  266. import { downloadExcel } from '@/libs/JGPrint.js'
  267. import stateIcon from '@/views/common/stateIcon'
  268. // 接口
  269. import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount, salesExport } from '@/api/sales'
  270. import moment from 'moment'
  271. export default {
  272. name: 'SalesList',
  273. components: { STable, VSelect, chooseCustomModal, rangeDate, auditModal, custList, stateIcon },
  274. mixins: [commonMixin],
  275. data () {
  276. return {
  277. spinning: false,
  278. tableHeight: 0, // 表格高度
  279. advanced: true, // 高级搜索 展开/关闭
  280. disabled: false, // 查询、重置按钮是否可操作
  281. exportLoading: false, // 导出loading
  282. openModal: false, // 选择客户弹框是否显示
  283. isByCustQuery: false, // 是否按客户查询
  284. showDiscount: false, // 显示折后总售价
  285. showCell: false, // 显示下拉选项
  286. time: [ // 创建时间
  287. getDate.getMonthDays(3).starttime,
  288. getDate.getMonthDays(3).endtime
  289. ],
  290. auditTime: [], // 审核时间
  291. outWareTime: [], // 出库时间
  292. // 查询参数
  293. queryParam: {
  294. beginDate: getDate.getMonthDays(3).starttime, // 开始创建时间
  295. endDate: getDate.getMonthDays(3).endtime, // 结束创建时间
  296. auditBeginDate: '', // 开始审核时间
  297. auditEndDate: '', // 结束审核时间
  298. outWarehouseBeginDate: '', // 开始出库时间
  299. outWarehouseEndDate: '', // 结束出库时间
  300. buyerNameCurrent: undefined, // 客户名称
  301. buyerSn: undefined, // 客户sn
  302. salesBillNo: '', // 销售单号
  303. purchaseBillNo: '', // 采购单号
  304. payType: undefined, // 支付方式
  305. settleStyleSn: undefined, // 收款方式
  306. billStatus: undefined, // 业务状态
  307. financialStatus: undefined, // 财务状态
  308. sourceType: undefined, // 单据来源
  309. distributionFlag: undefined // 是否铺货出库
  310. },
  311. totalData: { // 统计数据
  312. totalAmount: 0, // 总销价
  313. totalCategory: 0, // 总款数
  314. totalQty: 0, // 总数量
  315. totalRecord: 0 // 总条数
  316. },
  317. selType: '0', // 0零售 1铺货
  318. // 加载数据方法 必须为 Promise 对象
  319. loadData: parameter => {
  320. this.disabled = true
  321. this.spinning = true
  322. // 查询总计
  323. salesCount(Object.assign(parameter, this.queryParam)).then(res => {
  324. this.totalData = res.data
  325. })
  326. // 查询列表
  327. return salesList(Object.assign(parameter, this.queryParam)).then(res => {
  328. let data
  329. if (res.status == 200) {
  330. data = res.data
  331. const no = (data.pageNo - 1) * data.pageSize
  332. for (var i = 0; i < data.list.length; i++) {
  333. data.list[i].no = no + i + 1
  334. }
  335. this.disabled = false
  336. }
  337. this.spinning = false
  338. return data
  339. })
  340. },
  341. visibleAudit: false, // 审核弹框
  342. auditInfo: null, // 审核信息
  343. spinningAudit: false, // 审核操作loading
  344. distributionFlag: '0' // 是否铺货
  345. }
  346. },
  347. computed: {
  348. columns () {
  349. const _this = this
  350. const arr = [
  351. { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
  352. { title: '来源', dataIndex: 'sourceTypeDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  353. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: this.showDiscount ? '6%' : '9%', align: 'center' },
  354. { title: '客户名称', dataIndex: 'buyerNameCurrent', align: 'center', width: this.showDiscount ? '12%' : '15%', customRender: function (text) { return text || '--' } },
  355. { title: '总款数', dataIndex: 'totalCategory', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  356. { title: '总数量', dataIndex: 'totalQty', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  357. { title: '总售价', dataIndex: 'totalAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  358. // { title: '折扣金额', dataIndex: 'discountAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  359. // { title: '折后总售价', dataIndex: 'discountedAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  360. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  361. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  362. { title: '审核时间', dataIndex: 'auditDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  363. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  364. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '2%', align: 'center' },
  365. { title: '急件', scopedSlots: { customRender: 'oosFlag' }, width: '2%', align: 'center' },
  366. { title: '出库', scopedSlots: { customRender: 'waitOut' }, width: '2%', align: 'center' },
  367. { title: '收款', scopedSlots: { customRender: 'financial' }, width: '2%', align: 'center' },
  368. // { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  369. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  370. ]
  371. // 显示折扣
  372. if (this.showDiscount) {
  373. arr.splice(7, 0, { title: '折扣金额', dataIndex: 'discountAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  374. arr.splice(8, 0, { title: '折后总售价', dataIndex: 'discountedAmount', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  375. }
  376. return arr
  377. }
  378. },
  379. methods: {
  380. // 选择创建时间
  381. dateChange (date) {
  382. this.queryParam.beginDate = date[0]
  383. this.queryParam.endDate = date[1]
  384. },
  385. // 选择审核时间
  386. auditDateChange (date) {
  387. this.auditTime = date
  388. this.queryParam.auditBeginDate = date[0]
  389. this.queryParam.auditEndDate = date[1]
  390. },
  391. // 选择出库时间
  392. outWareDateChange (date) {
  393. this.outWareTime = date
  394. this.queryParam.outWarehouseBeginDate = date[0]
  395. this.queryParam.outWarehouseEndDate = date[1]
  396. },
  397. // 选择客户
  398. custChange (v, row) {
  399. console.log(v, row)
  400. if (row && row.customerSn) {
  401. this.queryParam.buyerSn = row.customerSn
  402. this.queryParam.buyerNameCurrent = undefined
  403. } else {
  404. this.queryParam.buyerNameCurrent = v
  405. this.queryParam.buyerSn = undefined
  406. }
  407. },
  408. // 打开新增弹框
  409. handleAdd (flag) {
  410. this.openModal = true
  411. this.distributionFlag = flag
  412. },
  413. // 打开审核弹框
  414. handleEexamine (row) {
  415. this.auditInfo = row
  416. this.visibleAudit = true
  417. },
  418. // 提交审核
  419. auditOrder (billStatus) {
  420. this.spinningAudit = true
  421. salesWriteAudit({
  422. id: this.auditInfo.id,
  423. billStatus: billStatus
  424. }).then(res => {
  425. if (res.status == 200) {
  426. this.visibleAudit = false
  427. this.$message.success(res.message)
  428. this.$refs.table.refresh()
  429. this.spinningAudit = false
  430. } else {
  431. this.visibleAudit = false
  432. this.spinningAudit = false
  433. }
  434. })
  435. },
  436. // 出库
  437. handleSend (row) {
  438. const _this = this
  439. this.$confirm({
  440. title: '提示',
  441. content: '确认要出库吗?',
  442. centered: true,
  443. closable: true,
  444. onOk () {
  445. _this.spinning = true
  446. salesWriteStockOut({
  447. salesBillSn: row.salesBillSn
  448. }).then(res => {
  449. if (res.status == 200) {
  450. _this.$message.success(res.message)
  451. _this.$refs.table.refresh()
  452. _this.spinning = false
  453. } else {
  454. _this.spinning = false
  455. }
  456. })
  457. }
  458. })
  459. },
  460. // 详情
  461. handleDetail (row) {
  462. this.$router.push({ name: 'salesNewDetail', params: { sn: row.salesBillSn } })
  463. },
  464. // 编辑
  465. handleEdit (row) {
  466. this.$router.push({ name: 'salesNewEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  467. },
  468. // 选择客户成功
  469. chooseCustomOk (data) {
  470. this.$router.push({ name: 'salesNewAdd', params: { id: data.id, sn: data.salesBillSn, priceType: data.priceType } })
  471. },
  472. // 删除
  473. handleDel (row, type) {
  474. const _this = this
  475. let content = '确认要删除吗?'
  476. if (type == 'cancel') {
  477. content = '确认要取消吗?'
  478. }
  479. this.$confirm({
  480. title: '提示',
  481. content: <div><div style='font-size:16px;margin-bottom:10px;'>{content}</div><div>销售单号:{row.salesBillNo}</div><div>客户名称:{row.buyerNameCurrent}</div></div>,
  482. centered: true,
  483. closable: true,
  484. onOk () {
  485. _this.spinning = true
  486. salesDel({ id: row.id, mainFlag: 1 }).then(res => {
  487. if (res.status == 200) {
  488. _this.$message.success(res.message)
  489. _this.$refs.table.refresh()
  490. _this.spinning = false
  491. } else {
  492. _this.spinning = false
  493. }
  494. })
  495. }
  496. })
  497. },
  498. // 查询列表
  499. searchForm (flag) {
  500. // 是否按客户查询
  501. if (!this.isByCustQuery) {
  502. const a = moment(this.queryParam.beginDate)
  503. const b = moment(this.queryParam.endDate)
  504. // 最多只能选择2年的时间区间
  505. if (b.diff(a, 'days') > 730) {
  506. this.$message.info('最多只能选择2年的时间区间')
  507. return false
  508. }
  509. this.$refs.table.refresh(!flag)
  510. } else {
  511. // 按客户查询
  512. if (this.queryParam.buyerSn) {
  513. this.$refs.table.refresh(!flag)
  514. } else {
  515. this.$message.info('请选择客户')
  516. return false
  517. }
  518. }
  519. },
  520. // 重置
  521. resetSearchForm () {
  522. this.resetData()
  523. this.$refs.table.refresh(true)
  524. },
  525. // 重置数据
  526. resetData (flag) {
  527. this.$refs.rangeDate.resetDate(flag ? '' : this.time)
  528. this.queryParam.beginDate = flag ? '' : getDate.getMonthDays(3).starttime
  529. this.queryParam.endDate = flag ? '' : getDate.getMonthDays(3).endtime
  530. this.queryParam.auditBeginDate = ''
  531. this.queryParam.auditEndDate = ''
  532. this.queryParam.outWarehouseBeginDate = ''
  533. this.queryParam.outWarehouseEndDate = ''
  534. this.auditTime = []
  535. this.outWareTime = []
  536. if (this.advanced) {
  537. this.$refs.auditRangeDate.resetDate('')
  538. this.$refs.outWareRangeDate.resetDate('')
  539. }
  540. this.queryParam.buyerNameCurrent = undefined
  541. this.queryParam.buyerSn = undefined
  542. this.queryParam.salesBillNo = ''
  543. this.queryParam.purchaseBillNo = ''
  544. this.queryParam.payType = undefined
  545. this.queryParam.settleStyleSn = undefined
  546. this.queryParam.billStatus = undefined
  547. this.queryParam.financialStatus = undefined
  548. this.queryParam.sourceType = undefined
  549. this.queryParam.distributionFlag = undefined
  550. this.$refs.custList.resetForm()
  551. if (!flag) {
  552. // 重置单据状态
  553. this.setIsHomeNav(this.$route.name, null)
  554. }
  555. },
  556. // 导出
  557. handleExport () {
  558. const _this = this
  559. const params = this.queryParam
  560. params.showDiscountAmountFlag = this.showDiscount ? 1 : 0
  561. this.exportLoading = true
  562. _this.spinning = true
  563. salesExport(params).then(res => {
  564. this.exportLoading = false
  565. _this.spinning = false
  566. if (res.type == 'application/json') {
  567. var reader = new FileReader()
  568. reader.addEventListener('loadend', function () {
  569. const obj = JSON.parse(reader.result)
  570. _this.$notification.error({
  571. message: '提示',
  572. description: obj.message
  573. })
  574. })
  575. reader.readAsText(res)
  576. } else {
  577. downloadExcel(res, '销售列表')
  578. }
  579. })
  580. },
  581. // 表格高度
  582. setTableH () {
  583. const tableSearchH = this.$refs.tableSearch.offsetHeight
  584. this.tableHeight = window.innerHeight - tableSearchH - 267
  585. },
  586. // 初始化页面
  587. pageInit () {
  588. const _this = this
  589. this.$nextTick(() => { // 页面渲染完成后的回调
  590. _this.setTableH()
  591. })
  592. // 是否打开的页签
  593. const a = this.$store.state.app.isNewTab
  594. // 是否要刷新列表
  595. const b = this.$store.state.app.updateList
  596. // 是否从首页点击进入
  597. const isHomeNav = this.getIsHomeNav()[this.$route.name]
  598. // 从首页进入,判断式新建还式待办查询
  599. if (isHomeNav) {
  600. // 新增
  601. if (isHomeNav.type == 'new') {
  602. this.resetSearchForm()
  603. this.openModal = true
  604. }
  605. // 待办
  606. if (isHomeNav.type == 'todo') {
  607. this.resetData(true)
  608. this.$refs.rangeDate.resetDate([isHomeNav.pageParams.beginDate, isHomeNav.pageParams.endDate])
  609. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  610. this.$refs.table.refresh(true)
  611. }
  612. } else {
  613. // 如果是新页签打开,则重置当前页面
  614. if (a && !b) {
  615. this.resetSearchForm()
  616. }
  617. // 仅刷新列表,不重置页面
  618. if (b || a == b) {
  619. this.$refs.table.refresh()
  620. }
  621. }
  622. }
  623. },
  624. watch: {
  625. // 展开收起查询条件
  626. advanced (newValue, oldValue) {
  627. const _this = this
  628. this.$nextTick(() => { // 页面渲染完成后的回调
  629. _this.setTableH()
  630. })
  631. },
  632. // 窗口变更时,需同时更改表格高度
  633. '$store.state.app.winHeight' (newValue, oldValue) {
  634. this.setTableH()
  635. },
  636. // 按客户查询复选框变更
  637. isByCustQuery (newValue, oldValue) {
  638. if (!newValue) {
  639. this.resetSearchForm()
  640. }
  641. }
  642. },
  643. activated () {
  644. this.pageInit()
  645. },
  646. beforeRouteEnter (to, from, next) {
  647. next(vm => {
  648. })
  649. }
  650. }
  651. </script>