list.vue 30 KB

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