edit.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  1. <template>
  2. <div v-if="showPage" class="jg-page-wrap salesEdit-news-wrap">
  3. <a-page-header :ghost="false" :backIcon="false" class="header-bar">
  4. <!-- 自定义的二级文字标题 -->
  5. <template slot="subTitle">
  6. <a class="billno" style="margin-right:15px;">单号:{{ detailData&&detailData.salesBillNo || '--' }}</a>
  7. <a-tag color="green" v-if="detailData.billStatusDictValue">{{ detailData.billStatusDictValue }}</a-tag>
  8. <a-tag color="orange" v-if="detailData.financialStatusDictValue">{{ detailData.financialStatusDictValue }}</a-tag>
  9. <span style="margin-left:10px;color: #666;">客户名称:{{ detailData&&detailData.buyerNameCurrent?detailData.buyerName?detailData.buyerNameCurrent==detailData.buyerName?detailData.buyerNameCurrent:detailData.buyerNameCurrent+'('+detailData.buyerName+')':detailData.buyerNameCurrent:'--' }}</span>
  10. <a-button
  11. id="salesEdit-edit-btn"
  12. type="link"
  13. style="margin-left:10px"
  14. v-if="detailData&&detailData.salesTragetType != 'DEALER'"
  15. size="small"
  16. class="button-info"
  17. @click="handleEdit"
  18. key="0"><a-icon type="edit" /> 编辑</a-button>
  19. <a-button id="purchaseNewOrderEdit-back-btn" type="link" @click="handleBack" class="button-default"> <a-icon type="rollback" /> 返回列表</a-button>
  20. <span style="margin-right:10px;color: #ED1C24;" v-if="detailData.sourceType==='XPRH_PURCHASE'">请注意:该销售单若为促销订单,增删改产品会影响促销活动</span>
  21. </template>
  22. <!-- 操作区,位于 title 行的行尾 -->
  23. <template slot="extra" v-if="$hasPermissions('B_salesPrint')">
  24. <div style="margin-top: 5px;">
  25. <PrintPanel ref="printBox" :disabled="dataSource.length==0" @handlePrint="handlePrint">
  26. <div style="padding:10px;" slot="extendCons">
  27. <a-checkbox v-model="printAllName" :checked="printAllName" id="salesQuery-printAllName">打印完整产品名称</a-checkbox>
  28. <a-checkbox v-model="printOrgCode" :checked="printOrgCode" id="salesQuery-printOrgCode">打印原厂编码</a-checkbox>
  29. <a-checkbox v-model="printPrice" :checked="printPrice" id="salesQuery-printPrice">打印售价</a-checkbox>
  30. <a-checkbox v-model="printRemarks" :checked="printRemarks" id="salesQuery-printRemarks">打印备注</a-checkbox>
  31. </div>
  32. </PrintPanel>
  33. <a-divider type="vertical" v-if="detailData&&detailData.totalCategory" />
  34. <a-button type="link" v-if="detailData&&detailData.totalCategory" @click="showSearch=!showSearch" :class="showSearch?'button-error':'button-default'"> <a-icon type="search" /> 筛选</a-button>
  35. <a-divider type="vertical" v-if="detailData&&detailData.totalCategory" />
  36. <a-button v-if="detailData&&detailData.totalCategory" id="salesNewOrderEdit-add-btn" type="link" @click="openChooseProduct=true"><a-icon type="plus" />添加产品</a-button>
  37. <a-divider type="vertical" v-if="detailData&&detailData.totalCategory" />
  38. <a-dropdown v-model="showCell" v-if="$hasPermissions('M_ShowAllCost')&&detailData&&detailData.totalCategory">
  39. <a-button type="link" class="button-default"> <a-icon type="setting" /> 显示</a-button>
  40. <a-menu slot="overlay">
  41. <a-menu-item>
  42. <a-checkbox v-model="isCosts" id="salesQuery-edit-cost">成本价</a-checkbox>
  43. </a-menu-item>
  44. </a-menu>
  45. </a-dropdown>
  46. <a-divider type="vertical" v-if="$hasPermissions('M_ShowAllCost')"/>
  47. <a-dropdown>
  48. <a-menu slot="overlay" @click="handleActions">
  49. <a-menu-item key="4">
  50. <a-icon type="import" />导入产品
  51. </a-menu-item>
  52. <a-menu-item key="3" v-if="shelfInfo&&shelfInfo.state=='ENABLE'">
  53. <a-icon type="hdd"/>货架产品
  54. </a-menu-item>
  55. <a-menu-item key="2">
  56. <a-icon type="close-square"/>清空列表
  57. </a-menu-item>
  58. <a-menu-item key="1">
  59. <a-icon type="rest" style="font-size: 14px;" />{{ isOwerEdit?'删除急件':'删除缺货' }}
  60. </a-menu-item>
  61. </a-menu>
  62. <a-button type="link" class="button-default"> <a-icon type="unordered-list" /> 更多</a-button>
  63. </a-dropdown>
  64. </div>
  65. </template>
  66. </a-page-header>
  67. <!-- 已选产品 -->
  68. <div class="choosedList-cont">
  69. <div class="choosed-table" v-if="detailData&&detailData.totalCategory">
  70. <!-- 搜索条件 -->
  71. <div class="table-page-search-wrapper" style="margin-bottom:0;" v-if="showSearch">
  72. <a-form-model :model="productForm" ref="ruleForm" layout="inline" @keyup.enter.native="$refs.table.refresh(true)" >
  73. <a-row :gutter="10">
  74. <a-col :md="5" :sm="24">
  75. <a-form-model-item label="产品编码">
  76. <a-input v-model.trim="productForm.productCode" allowClear placeholder="输入产品编码" />
  77. </a-form-model-item>
  78. </a-col>
  79. <a-col :md="5" :sm="24">
  80. <a-form-model-item label="产品名称">
  81. <a-input v-model.trim="productForm.productName" allowClear placeholder="输入产品名称" />
  82. </a-form-model-item>
  83. </a-col>
  84. <a-col :md="4" :sm="24" v-if="isOwerEdit">
  85. <a-form-item label="是否为急件">
  86. <a-select allowClear v-model="productForm.oosFlag" placeholder="请选择是否">
  87. <a-select-option value="1">
  88. </a-select-option>
  89. <a-select-option value="0">
  90. </a-select-option>
  91. </a-select>
  92. </a-form-item>
  93. </a-col>
  94. <!-- <a-col :md="4" :sm="24" v-else>
  95. <a-form-item label="是否为缺货">
  96. <a-select allowClear v-model="productForm.oosFlag" placeholder="请选择是否">
  97. <a-select-option value="1">
  98. </a-select-option>
  99. <a-select-option value="0">
  100. </a-select-option>
  101. </a-select>
  102. </a-form-item>
  103. </a-col> -->
  104. <a-col :md="4" :sm="24">
  105. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="salesEdit-refresh">查询</a-button>
  106. <a-button style="margin-left: 5px" @click="resetForm" id="salesEdit-reset">重置</a-button>
  107. </a-col>
  108. </a-row>
  109. </a-form-model>
  110. </div>
  111. <div class="discount-box">
  112. </div>
  113. <!-- 已选配件列表 -->
  114. <s-table
  115. class="sTable"
  116. ref="table"
  117. size="small"
  118. :rowKey="(record) => record.id"
  119. :columns="columns"
  120. :data="loadData"
  121. :scroll="{ y: tableHeight }"
  122. :defaultLoadData="false"
  123. :pageSize="30"
  124. bordered>
  125. <div slot="costTitle">
  126. <a-tooltip placement="top">
  127. <template slot="title">
  128. 系统中不同批次的产品,成本价可能不同,此值是按照实际出库批次的成本计算得到。
  129. </template>
  130. <span style="margin-right: 5px;">实际总成本</span> <a-icon type="question-circle" />
  131. </a-tooltip>
  132. </div>
  133. <!-- 产品名称 -->
  134. <template slot="productName" slot-scope="text, record">
  135. <a-tag color="blue" v-if="record.shelfPlaceCode">{{ record.shelfPlaceCode }}</a-tag>
  136. <span :title="text">{{ text }}</span>
  137. </template>
  138. <!-- 产品编码 -->
  139. <template slot="productCode" slot-scope="text, record">
  140. <div v-if="detailData">
  141. <div v-if="isOwerEdit">
  142. <a-badge count="急" v-if="record.oosFlag == 1">
  143. <div style="padding-right: 15px;">{{ text }}</div>
  144. </a-badge>
  145. <span v-else>{{ text }}</span>
  146. </div>
  147. <div v-else>
  148. <a-badge count="急" v-if="isAudit&&record.oosFlag == 1">
  149. <div style="padding-right: 15px;">{{ text }}</div>
  150. </a-badge>
  151. <a-badge count="缺" v-else-if="!isAudit&&(!record.currentStockQty || record.currentStockQty < record.qty)">
  152. <div style="padding-right: 15px;">{{ text }}</div>
  153. </a-badge>
  154. <span v-else>{{ text }}</span>
  155. </div>
  156. </div>
  157. </template>
  158. <!-- 售价 -->
  159. <template slot="price" slot-scope="text, record">
  160. <div style="display:flex;align-items: center;" :class="record.cost > record.price?'redBg-row':''">
  161. <div v-if="record.cost > record.price">
  162. <a-tooltip placement="top">
  163. <template slot="title">
  164. 售价低于成本价
  165. </template>
  166. <a-icon type="warning" />
  167. </a-tooltip>
  168. </div>
  169. <a-input-number
  170. size="small"
  171. v-model="record.price"
  172. :precision="2"
  173. :min="0"
  174. :max="999999"
  175. placeholder="请输入"
  176. @blur="e => priceBlur(e.target.value, record)"
  177. style="flex-grow: 1;margin-left: 3px;text-align: right;"
  178. />
  179. </div>
  180. </template>
  181. <!-- 销售数量 -->
  182. <template slot="salesNums" slot-scope="text, record">
  183. <a-input-number
  184. id="salesEdit-salesNums"
  185. size="small"
  186. v-model="record.qty"
  187. :precision="0"
  188. :min="1"
  189. :max="999999"
  190. placeholder="请输入"
  191. @blur="e => qtyBlur(e.target.value, record)"
  192. style="width: 100%;" />
  193. </template>
  194. <!-- 操作 -->
  195. <template slot="action" slot-scope="text, record">
  196. <a-button size="small" v-if="record.oosFlag == 0 && isOwerEdit" type="link" class="button-primary" @click="handleViewDetail(record)">出库明细</a-button>
  197. <a-button
  198. size="small"
  199. type="link"
  200. :loading="delLoading"
  201. class="button-error"
  202. @click="handleDel(record)"
  203. id="productInfoList-Del">删除</a-button>
  204. </template>
  205. </s-table>
  206. </div>
  207. <div class="choosed-table" v-else>
  208. <div v-if="!spinning&&detailData.totalCategory==0">
  209. <a-empty
  210. :image="simpleImage"
  211. :image-style="{
  212. height: '60px',
  213. }"
  214. >
  215. <span slot="description"> 暂无产品 </span>
  216. <a-button type="primary" class="button-error" @click="openChooseProduct=true"><a-icon type="plus" />立即添加产品</a-button>
  217. </a-empty>
  218. </div>
  219. <div style="text-align: center;padding: 30px 50px;" v-if="spinning">
  220. <a-spin :spinning="spinning" tip="Loading..."></a-spin>
  221. </div>
  222. </div>
  223. <!-- 底部栏 -->
  224. <div class="footer-bar" v-if="detailData&&detailData.totalCategory">
  225. <!-- 总计 -->
  226. <div v-if="detailData" class="total-bar">
  227. <div>
  228. 总款数:<span>{{ detailData&&(detailData.totalCategory || detailData.totalCategory==0) ? detailData.totalCategory : '--' }}</span>,
  229. 总数量:<span>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</span>,
  230. 赠品总数量:<span>{{ detailData&&(detailData.giftQty || detailData.giftQty==0) ? detailData.giftQty : '--' }}</span>,
  231. <template v-if="isCosts">
  232. 总成本价:<span class="red">{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</span>,
  233. 毛利:<span class="red">{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</span>,
  234. </template>
  235. <div style="display: inline-block;">
  236. 总售价:<span class="red">{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</span>
  237. </div>
  238. </div>
  239. <div>
  240. <div style="display: inline-block;">
  241. 折扣金额:
  242. <a-input-number
  243. id="discount"
  244. size="small"
  245. v-model.trim="detailData.discountAmount"
  246. @blur="salesDiscount"
  247. :min="0"
  248. :precision="2"
  249. :max="999999"/>
  250. 折扣:<span class="red">{{ detailData&&(detailData.discountRate || detailData.discountRate==0) ? detailData.discountRate+'%' : '--' }}</span>,
  251. </div>
  252. <div class="totalPrice" style="display: inline-block;padding:0;">
  253. 折后合计:<strong>{{ detailData&&(detailData.discountedAmount || detailData.discountedAmount==0) ? toThousands(detailData.discountedAmount) : '--' }}</strong>
  254. </div>
  255. </div>
  256. </div>
  257. <div>
  258. <a-dropdown>
  259. <a-menu slot="overlay">
  260. <a-menu-item key="1"> <a-checkbox :value="0" :checked="tbForm.indexOf('AUDIT')>=0" @change="(e)=>{tbFormChange(e,0)}" id="salesQuery-tbsh">同步审核</a-checkbox> </a-menu-item>
  261. <a-menu-item key="2"> <a-checkbox :value="1" :checked="tbForm.indexOf('STOCK_OUT')>=0" @change="(e)=>{tbFormChange(e,1)}" id="salesQuery-tbck">同步出库</a-checkbox> </a-menu-item>
  262. <a-menu-item key="3"> <a-checkbox :value="2" :checked="tbForm.indexOf('SETTLE')>=0" @change="(e)=>{tbFormChange(e,2)}" id="salesQuery-tbsk">同步收款</a-checkbox></a-menu-item>
  263. </a-menu>
  264. <a-button style="margin-left: 8px" size="large"> 选择同步操作 <a-icon type="down" /> </a-button>
  265. </a-dropdown>
  266. </div>
  267. <div>
  268. <a-button
  269. type="primary"
  270. id="salesEdit-handleSubmit"
  271. size="large"
  272. class="button-primary"
  273. :loading="spinning"
  274. @click="enableFundAccount && tbForm.length == 3 ? handleSettleAcountPay(null,0) : handleSubmit({})"
  275. style="padding: 0 60px;">提交</a-button>
  276. </div>
  277. </div>
  278. </div>
  279. <!-- 选择客户弹框 -->
  280. <choose-custom-modal ref="custModal" :show="openModal" @updateData="updateData" @cancel="openModal=false" />
  281. <!-- 导入产品 -->
  282. <importGuideModal
  283. :openModal="openGuideModal"
  284. :params="{salesBillSn: $route.params.sn, salesBillNo:detailData?detailData.salesBillNo:''}"
  285. @close="openGuideModal=false"
  286. @ok="hanldeImprotOk"></importGuideModal>
  287. <!-- 收付款弹框 -->
  288. <settleModal ref="settleModal" @ok="settleAcountPay" :openModal="openSettleModal" @close="openSettleModal=false"></settleModal>
  289. <!-- 出库明细 -->
  290. <outInDetialModal ref="outInDetialModal" outBizType="SALES" :openModal="showOutInModal" @close="showOutInModal=false"></outInDetialModal>
  291. <!-- 销售记录 -->
  292. <product-salesRecord-modal ref="salseRecord" :openModal="openSalesRecordModal" @close="openSalesRecordModal=false" />
  293. <!-- 添加产品 -->
  294. <chooseProductModal
  295. ref="partQuery"
  296. :newLoading="isInster"
  297. :showModal="openChooseProduct"
  298. :checkedList="checkedProductList"
  299. @viewRecord="hanldSalesRecord"
  300. @close="openChooseProduct=false"
  301. @add="insterProduct"
  302. ></chooseProductModal>
  303. <!-- 选择货架产品 -->
  304. <chooseShelfProduct
  305. v-if="showShelfModal"
  306. ref="chooseShelfProduct"
  307. @viewRecord="hanldSalesRecord"
  308. @add="insterProduct"
  309. @plAdd="plInsterProduct"
  310. :baseData="shelfInfo"
  311. :openModal="showShelfModal"
  312. @close="showShelfModal=false"></chooseShelfProduct>
  313. </div>
  314. </template>
  315. <script>
  316. import { commonMixin } from '@/utils/mixin'
  317. import { mapActions } from 'vuex'
  318. import { Empty } from 'ant-design-vue'
  319. import { STable, VSelect } from '@/components'
  320. import chooseProductModal from './chooseProductModal.vue'
  321. import chooseCustomModal from './chooseCustomModal.vue'
  322. import importGuideModal from './importGuideModal.vue'
  323. import settleModal from '@/views/financialManagement/settleModal/settleModal.vue'
  324. import productSalesRecordModal from './productSalesRecordModal.vue'
  325. import { stockByProductSn } from '@/api/stock'
  326. import { queryByCustomerSn } from '@/api/shelf'
  327. import { salesDetail, salesWriteSubmit, salesWriteDiscount, salesDetailPrint, salesDetailExport, salesDel } from '@/api/sales'
  328. import { salesDetailList, salesDetailInsert, salesDetailInsertBatch, salesDetailUpdatePrice, salesDetailUpdateQty, salesDetailDel, salesDetailDelAll, salesDetailInsertImport, queryCheckedList } from '@/api/salesDetail'
  329. import outInDetialModal from './outInDetialModal.vue'
  330. import chooseShelfProduct from './chooseShelfProduct.vue'
  331. import PrintPanel from '@/views/common/printPanel.vue'
  332. import { hdPrint } from '@/libs/JGPrint'
  333. export default {
  334. name: 'SalesEdit',
  335. components: { STable, VSelect, chooseProductModal, chooseCustomModal, PrintPanel, importGuideModal, settleModal, outInDetialModal, chooseShelfProduct, productSalesRecordModal },
  336. mixins: [commonMixin],
  337. data () {
  338. return {
  339. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
  340. tableHeight: 0,
  341. showOutInModal: false, // 出入库明细
  342. showCell: false,
  343. showPage: false,
  344. spinning: false,
  345. showSearch: false,
  346. openChooseProduct: false,
  347. orderId: null, // 销售单id
  348. salesBillSn: null, // 销售单sn
  349. disabled: false, // 查询、重置按钮是否可操作
  350. isInster: false, // 是否正在添加产品
  351. openModal: false, // 客户弹框
  352. openSalesRecordModal: false, // 销售记录
  353. openGuideModal: false, // 导入产品弹框
  354. openSettleModal: false, // 打开收款弹框
  355. enableFundAccount: false, // 是否开启资金账户管理
  356. showShelfModal: false, // 货架产品弹框
  357. checkedProductList: [], // 已选所有产品
  358. delLoading: false,
  359. detailData: { discountAmount: 0, id: null, salesBillSn: '' }, // 订单基础数据
  360. dataSource: [],
  361. productForm: {
  362. productName: '',
  363. productCode: '',
  364. oosFlag: undefined,
  365. orderBy: 'sales_bill_detail.CREATE_DATE desc'
  366. },
  367. tbForm: [], // 同步操作
  368. printOrgCode: false, // 打印原创编码
  369. printAllName: false, // 打印全部名称
  370. printRemarks: false, // 打印备注
  371. printPrice: false,
  372. // 加载数据方法 必须为 Promise 对象
  373. loadData: parameter => {
  374. this.disabled = true
  375. this.spinning = true
  376. this.productForm.salesBillSn = this.$route.params.sn
  377. this.getChoosedList({ salesBillSn: this.$route.params.sn })
  378. return salesDetailList(Object.assign(parameter, this.productForm)).then(res => {
  379. let data
  380. if (res.status == 200) {
  381. data = res.data
  382. const no = (data.pageNo - 1) * data.pageSize
  383. for (var i = 0; i < data.list.length; i++) {
  384. data.list[i].no = no + i + 1
  385. data.list[i].qtyBackups = data.list[i].qty
  386. data.list[i].priceBackups = data.list[i].price
  387. }
  388. this.disabled = false
  389. this.dataSource = data.list || []
  390. }
  391. this.spinning = false
  392. return data
  393. })
  394. },
  395. printerType: 'NEEDLE', // 打印机类型
  396. isCosts: false, // 是否显示成本价
  397. shelfInfo: null, // 是否有货架
  398. discountAmountBak: null
  399. }
  400. },
  401. computed: {
  402. // 是否自建单据
  403. isOwerEdit () {
  404. return this.detailData && this.detailData.sourceType == 'SALES'
  405. },
  406. // 是否审核通过
  407. isAudit () {
  408. return this.detailData && (this.detailData.billStatus == 'WAIT_OUT_WAREHOUSE' || this.detailData.billStatus == 'FINISH')
  409. },
  410. columns () {
  411. const _this = this
  412. const arr = [
  413. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  414. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '11%', scopedSlots: { customRender: 'productCode' }, align: 'center' },
  415. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '15%', align: 'left', scopedSlots: { customRender: 'productName' }, ellipsis: true },
  416. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  417. { title: '品牌', dataIndex: 'dealerProductEntity.productBrandName', width: '8%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  418. // { title: '仓库', dataIndex: 'warehouseEntity.name', width: '8%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  419. // { title: '仓位', dataIndex: 'warehouseLocationEntity.name', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  420. { title: '售价', dataIndex: 'price', scopedSlots: { customRender: 'price' }, width: '7%', align: 'center' },
  421. { title: '销售数量', scopedSlots: { customRender: 'salesNums' }, width: '7%', align: 'center' },
  422. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  423. { title: '售价小计', dataIndex: 'totalAmount', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  424. { title: '折后小计', dataIndex: 'discountedAmount', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  425. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  426. ]
  427. // 下级创建,不显示仓库仓位
  428. if (!this.isOwerEdit) {
  429. arr.splice(7, 0, { title: '库存数量', dataIndex: 'currentStockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  430. } else {
  431. arr.splice(5, 0, { title: '仓库', dataIndex: 'warehouseEntity.name', width: '8%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } })
  432. arr.splice(6, 0, { title: '仓位', dataIndex: 'warehouseLocationEntity.name', width: '8%', align: 'center', customRender: function (text) { return text || '--' } })
  433. }
  434. if (this.detailData && this.detailData.sourceType && this.detailData.sourceType === 'XPRH_PURCHASE') {
  435. arr.splice(10, 0, { title: <a-tooltip placement="bottom" title='返券金额以销售单完结时的活动规则为准'>返券金额&nbsp;<a-icon type="question-circle" /></a-tooltip>, dataIndex: 'giveAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  436. }
  437. // 实际总成本
  438. if (this.isCosts) {
  439. arr.splice(!this.isOwerEdit ? 11 : 12, 0, { slots: { title: 'costTitle' }, dataIndex: 'totalCost', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  440. }
  441. return arr
  442. }
  443. },
  444. methods: {
  445. ...mapActions(['GetSettleAccountState']),
  446. handleActions (e) {
  447. if (e.key == 4) {
  448. this.openGuideModal = true
  449. }
  450. if (e.key == 3) {
  451. this.showShelfModal = true
  452. }
  453. if (e.key == 2) { // 清空列表
  454. this.delSalerOrder()
  455. }
  456. if (e.key == 1) { // 删除急件
  457. this.delSalerOrder(this.isOwerEdit ? 1 : 2)
  458. }
  459. },
  460. // 打印预览/快捷打印
  461. handlePrint (type, printerType) {
  462. const _this = this
  463. _this.spinning = true
  464. let url = salesDetailPrint
  465. const params = {
  466. sn: this.outBizSn || this.$route.params.sn,
  467. printOrgCode: this.printOrgCode ? 1 : 0,
  468. printAllName: this.printAllName ? 1 : 0,
  469. remarksShowFlag: this.printRemarks ? 1 : 0,
  470. priceFlag: this.printPrice ? 1 : 0
  471. }
  472. if (type == 'export') { // 导出
  473. url = salesDetailExport
  474. }
  475. // 打印或导出
  476. hdPrint(printerType, type, url, params, '销售单', function () {
  477. _this.spinning = false
  478. _this.$refs.printBox.hovered = false
  479. })
  480. },
  481. tbFormChange (e, val) {
  482. this.tbForm = []
  483. const tbTypes = ['AUDIT', 'STOCK_OUT', 'SETTLE']
  484. if (e.target.checked) {
  485. for (let i = val; i >= 0; i--) {
  486. this.tbForm.push(tbTypes[i])
  487. }
  488. } else {
  489. this.tbForm = []
  490. }
  491. },
  492. // 编辑客户信息
  493. handleEdit () {
  494. this.openModal = true
  495. this.$refs.custModal.editCust(this.detailData)
  496. },
  497. // 查看销售记录
  498. hanldSalesRecord (row) {
  499. console.log(row)
  500. this.openSalesRecordModal = true
  501. this.$refs.salseRecord.getDetail(this.detailData.buyerSn, row.productSn, row)
  502. },
  503. // 查询已选所以产品
  504. getChoosedList (params) {
  505. this.isInster = true
  506. queryCheckedList(params).then(res => {
  507. this.checkedProductList = res.data || []
  508. this.isInster = false
  509. })
  510. },
  511. // 更新产品列表
  512. updateData (priceType) {
  513. // 价格类型变更
  514. if (priceType != this.$route.params.priceType) {
  515. this.getOrderDetail(true)
  516. this.$router.push({ name: 'salesNewEdit', params: { id: this.orderId, sn: this.salesBillSn, priceType: priceType } })
  517. } else {
  518. this.getOrderDetail(true)
  519. }
  520. },
  521. // 非下级创建的单据,修改数量时校验库存
  522. validStock (val, record) {
  523. const _this = this
  524. this.spinning = true
  525. // 校验库存
  526. stockByProductSn({ productSn: record.productSn }).then(res => {
  527. if (res.status == 200) {
  528. if (res.data && (!res.data.currentStockQty || val <= res.data.currentStockQty)) {
  529. _this.changeQty(record)
  530. } else {
  531. this.$confirm({
  532. title: '提示',
  533. content: '库存不足,确认添加为急件吗?',
  534. centered: true,
  535. closable: true,
  536. onOk () {
  537. _this.changeQty(record)
  538. },
  539. onCancel () {
  540. record.qty = record.qtyBackups
  541. _this.spinning = false
  542. }
  543. })
  544. }
  545. } else {
  546. this.spinning = false
  547. record.qty = record.qtyBackups
  548. }
  549. })
  550. },
  551. // 修改已选产品数量
  552. changeQty (record) {
  553. salesDetailUpdateQty({
  554. id: record.id,
  555. salesBillSn: record.salesBillSn,
  556. productSn: record.productSn,
  557. salesBillDetailSn: record.salesBillDetailSn,
  558. qty: record.qty,
  559. price: record.price
  560. }).then(res => {
  561. this.getOrderDetail(false, true)
  562. if (res.status == 200) {
  563. this.$message.info(res.message)
  564. }
  565. this.spinning = false
  566. })
  567. },
  568. // 已选产品 销售数量 input 输入框 blur
  569. qtyBlur (val, record) {
  570. this.dataSource = record || []
  571. if (val && val != record.qtyBackups) {
  572. // 自建的单据,修改数量时校验库存
  573. if (this.isOwerEdit) {
  574. this.validStock(val, record)
  575. } else {
  576. this.changeQty(record)
  577. }
  578. } else {
  579. record.qty = record.qtyBackups
  580. }
  581. },
  582. // 已选产品 售价 input 输入框 blur
  583. priceBlur (val, record) {
  584. this.dataSource = record || []
  585. // 光标移出,值发生改变再调用编辑接口
  586. if (val && val != record.priceBackups) {
  587. this.spinning = true
  588. salesDetailUpdatePrice({
  589. id: record.id,
  590. salesBillSn: record.salesBillSn,
  591. productSn: record.productSn,
  592. salesBillDetailSn: record.salesBillDetailSn,
  593. qty: record.qty,
  594. price: record.price
  595. }).then(res => {
  596. this.getOrderDetail(false, true)
  597. if (res.status == 200) {
  598. this.$message.info(res.message)
  599. this.spinning = false
  600. } else {
  601. this.spinning = false
  602. }
  603. })
  604. } else {
  605. record.price = record.priceBackups
  606. }
  607. },
  608. // 重置列表
  609. resetForm () {
  610. this.productForm = {
  611. productName: '',
  612. productCode: '',
  613. oosFlag: undefined,
  614. orderBy: 'sales_bill_detail.CREATE_DATE desc'
  615. }
  616. this.$nextTick(() => {
  617. this.$refs.table.refresh()
  618. })
  619. },
  620. // 返回
  621. handleBack () {
  622. this.$router.push({ name: 'salesNewList' })
  623. },
  624. // 打折
  625. salesDiscount () {
  626. if (this.discountAmountBak == this.detailData.discountAmount) {
  627. return false
  628. }
  629. this.spinning = true
  630. salesWriteDiscount({
  631. discountAmount: this.detailData.discountAmount || 0,
  632. salesBillSn: this.detailData.salesBillSn,
  633. id: this.detailData.id
  634. }).then(res => {
  635. if (res.status == 200) {
  636. this.getOrderDetail(true)
  637. } else {
  638. this.spinning = false
  639. }
  640. })
  641. },
  642. // 清空已选产品
  643. delSalerOrder (flag) {
  644. const _this = this
  645. this.$confirm({
  646. title: '提示',
  647. content: !flag ? '确认要清空已选产品列表吗?' : (flag == 1 ? '确认要删除所有急件吗?删除后不可恢复。' : '确认要删除所有缺货吗?删除后不可恢复。'),
  648. centered: true,
  649. closable: true,
  650. onOk () {
  651. _this.spinning = true
  652. const params = { id: _this.orderId, oosFlag: !flag ? undefined : 1 }
  653. salesDel(params).then(res => {
  654. if (res.status == 200) {
  655. _this.getOrderDetail(true)
  656. if (!flag) {
  657. _this.dataSource = []
  658. }
  659. _this.$message.success(res.message)
  660. }
  661. _this.spinning = false
  662. })
  663. }
  664. })
  665. },
  666. // 出入库明细
  667. handleViewDetail (row) {
  668. this.showOutInModal = true
  669. this.$refs.outInDetialModal.getData(row)
  670. },
  671. // 删除产品
  672. handleDel (row) {
  673. row
  674. const _this = this
  675. this.$confirm({
  676. title: '提示',
  677. content: '确认要删除吗?',
  678. centered: true,
  679. closable: true,
  680. onOk () {
  681. _this.delLoading = true
  682. _this.spinning = true
  683. salesDetailDel({ id: row.id }).then(res => {
  684. if (res.status == 200) {
  685. _this.getOrderDetail(false, true)
  686. }
  687. _this.$message.info(res.message)
  688. _this.delLoading = false
  689. _this.spinning = false
  690. })
  691. }
  692. })
  693. },
  694. // 添加产品
  695. insterProduct (row) {
  696. // 防止多次添加产品
  697. if (this.isInster) { return }
  698. const _this = this
  699. // 自建的单据显示库存不足时
  700. if (row.currentQty < row.salesNums && this.isOwerEdit) {
  701. _this.$confirm({
  702. title: '提示',
  703. content: '库存不足,确认添加为急件吗?',
  704. centered: true,
  705. closable: true,
  706. onOk () {
  707. _this.isPutCostDyPrice(row)
  708. }
  709. })
  710. } else {
  711. _this.isPutCostDyPrice(row)
  712. }
  713. },
  714. // 判断售价低于成本价
  715. isPutCostDyPrice (row) {
  716. const _this = this
  717. if (row.putCost > row.price) {
  718. // 销售价低于成本价
  719. _this.$confirm({
  720. title: '提示',
  721. content: '售价低于成本价,确认要添加吗?',
  722. centered: true,
  723. closable: true,
  724. onOk () {
  725. _this.saveNewProduct(row)
  726. }
  727. })
  728. } else {
  729. _this.saveNewProduct(row)
  730. }
  731. },
  732. // 保存添加的产品到销售列表
  733. saveNewProduct (row) {
  734. this.$message.loading('正在添加产品...', 1)
  735. this.isInster = true
  736. // this.spinning = true
  737. salesDetailInsert({
  738. buyerSn: this.detailData.buyerSn,
  739. productSn: row.productSn,
  740. cost: row.putCost,
  741. // productCode: row.productCode,
  742. // productOrigCode: row.productOrigCode,
  743. price: row.price,
  744. priceLevel: row.priceLevel,
  745. qty: row.salesNums,
  746. salesBillSn: this.detailData.salesBillSn,
  747. salesBillNo: this.detailData.salesBillNo,
  748. warehouseSn: row.warehouseSn,
  749. warehouseLocationSn: row.warehouseLocationSn,
  750. stockSn: row.stockSn
  751. }).then(res => {
  752. if (res.status == 200) {
  753. this.getOrderDetail(true)
  754. if (this.showShelfModal) {
  755. this.$refs.chooseShelfProduct.reload()
  756. }
  757. } else {
  758. if (res.errCode == 'VALID_F_00001') {
  759. this.productForm = {
  760. productName: '',
  761. productCode: row.productCode || '',
  762. orderBy: 'sales_bill_detail.CREATE_DATE desc'
  763. }
  764. this.showSearch = true
  765. this.$refs.table.refresh(true)
  766. }
  767. this.isInster = false
  768. }
  769. // this.spinning = false
  770. })
  771. },
  772. // 批量添加接口
  773. plInsterProduct (list) {
  774. const params = []
  775. list.map(item => {
  776. params.push({
  777. buyerSn: this.detailData.buyerSn,
  778. productSn: item.productSn,
  779. cost: item.putCost,
  780. price: item.price,
  781. priceLevel: item.priceLevel,
  782. qty: item.salesNums,
  783. salesBillSn: this.detailData.salesBillSn,
  784. salesBillNo: this.detailData.salesBillNo,
  785. stockSn: item.stockSn
  786. })
  787. })
  788. this.$message.loading('正在批量添加产品...', 1)
  789. salesDetailInsertBatch(params).then(res => {
  790. if (res.status == 200) {
  791. this.getOrderDetail(true)
  792. if (this.showShelfModal) {
  793. this.$refs.chooseShelfProduct.reload()
  794. }
  795. }
  796. })
  797. },
  798. // 销售单详情
  799. getOrderDetail (flag, resetTable) {
  800. const vm = this
  801. vm.spinning = true
  802. salesDetail({ id: vm.$route.params.id }).then(res => {
  803. if (res.status == 200) {
  804. vm.detailData = res.data
  805. vm.discountAmountBak = vm.detailData.discountAmount
  806. if (res.data.delFlag == 1) {
  807. vm.$message.info('该销售单已删除')
  808. vm.handleBack()
  809. return false
  810. }
  811. if (flag) {
  812. const buyerSn = (vm.detailData && vm.detailData.buyerSn && vm.detailData.sourceType && vm.detailData.sourceType == 'PURCHASE') ? '' : vm.detailData.buyerSn
  813. const priceType = vm.$route.params.priceType
  814. vm.$refs.partQuery.pageInit(buyerSn, priceType, vm.salesBillSn)
  815. if (vm.detailData.totalCategory) {
  816. vm.resetForm()
  817. } else {
  818. vm.spinning = false
  819. vm.checkedProductList = []
  820. }
  821. // 查询关联的客户货架信息
  822. if (vm.detailData && vm.detailData.buyerSn) {
  823. vm.getShelfQueryByCustomer()
  824. }
  825. } else {
  826. if (resetTable) {
  827. vm.$refs.table.refresh()
  828. } else {
  829. vm.spinning = false
  830. }
  831. }
  832. }
  833. })
  834. },
  835. // 查询关联的客户货架信息
  836. getShelfQueryByCustomer () {
  837. queryByCustomerSn({ sn: this.detailData.buyerSn }).then(res => {
  838. if (res.data) {
  839. this.shelfInfo = Object.assign(res.data, { salePriceType: this.$route.params.priceType, salesBillSn: this.salesBillSn })
  840. } else {
  841. this.shelfInfo = null
  842. }
  843. })
  844. },
  845. // 提交销售单
  846. handleSubmit (params) {
  847. this.spinning = true
  848. const submitTypes = this.tbForm.join(',')
  849. salesWriteSubmit({ id: this.orderId, submitTypes: submitTypes, ...params }).then(res => {
  850. console.log(res)
  851. if (res.status == 200) {
  852. this.handleBack()
  853. this.$message.success(res.message)
  854. this.spinning = false
  855. } else {
  856. this.spinning = false
  857. }
  858. })
  859. },
  860. // 开启结算账户功能收款, type:0 单条收款,1 批量收款
  861. handleSettleAcountPay (row, type) {
  862. this.openSettleModal = true
  863. const data = {
  864. totalAmount: this.detailData.discountedAmount,
  865. settleClientName: '',
  866. title: '收款',
  867. type,
  868. row
  869. }
  870. this.$nextTick(() => {
  871. this.$refs.settleModal.setData(data)
  872. })
  873. },
  874. // 去收款
  875. settleAcountPay (form, data) {
  876. const params = {}
  877. // 资金管理开启
  878. if (this.enableFundAccount) {
  879. params.settleStyleSn = form.settleStyleSn
  880. params.settleAccountSn = form.settleAccountSn
  881. }
  882. this.spinning = true
  883. this.handleSubmit(params)
  884. },
  885. // 确认导入明细
  886. hanldeImprotOk (obj) {
  887. this.spinning = true
  888. salesDetailInsertImport(obj).then(res => {
  889. if (res.status == 200) {
  890. this.getOrderDetail(true)
  891. }
  892. this.spinning = false
  893. })
  894. },
  895. setTableH () {
  896. this.tableHeight = window.innerHeight - (this.showSearch ? 42 : 0) - 300
  897. },
  898. pageInit () {
  899. const vm = this
  900. vm.$nextTick(() => {
  901. vm.setTableH()
  902. vm.orderId = vm.$route.params.id
  903. vm.salesBillSn = vm.$route.params.sn
  904. // 是否默认打印原厂编码
  905. vm.printOrgCode = localStorage.getItem('printOrgCode-' + this.$store.state.user.info.orgId) == 'true'
  906. vm.printAllName = localStorage.getItem('printAllName-' + this.$store.state.user.info.orgId) == 'true'
  907. vm.printRemarks = localStorage.getItem('printRemarks-' + this.$store.state.user.info.orgId) == 'true'
  908. vm.printPrice = localStorage.getItem('printPrice-' + this.$store.state.user.info.orgId) == 'true'
  909. vm.getOrderDetail(true)
  910. })
  911. }
  912. },
  913. watch: {
  914. printOrgCode (newValue, oldValue) {
  915. localStorage.setItem('printOrgCode-' + this.$store.state.user.info.orgId, newValue)
  916. },
  917. printAllName (newValue, oldValue) {
  918. localStorage.setItem('printAllName-' + this.$store.state.user.info.orgId, newValue)
  919. },
  920. printPrice (newValue, oldValue) {
  921. localStorage.setItem('printPrice-' + this.$store.state.user.info.orgId, newValue)
  922. },
  923. printRemarks (newValue, oldValue) {
  924. localStorage.setItem('printRemarks-' + this.$store.state.user.info.orgId, newValue)
  925. },
  926. showSearch (newValue, oldValue) {
  927. this.setTableH()
  928. },
  929. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  930. this.setTableH()
  931. }
  932. },
  933. mounted () {
  934. this.showPage = true
  935. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  936. this.pageInit()
  937. }
  938. },
  939. activated () {
  940. this.showPage = true
  941. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  942. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  943. this.pageInit()
  944. }
  945. // 结算账户状态查询
  946. if (this.$hasPermissions('M_fundAccountList') && this.$hasPermissions('B_fundAccountEnable')) {
  947. this.GetSettleAccountState().then(res => {
  948. if (res.status == 200) {
  949. this.enableFundAccount = res.data.functionEnableFlag == 1
  950. }
  951. })
  952. }
  953. },
  954. beforeRouteEnter (to, from, next) {
  955. next(vm => {})
  956. }
  957. }
  958. </script>
  959. <style lang="less">
  960. .salesEdit-news-wrap{
  961. position: relative;
  962. height: 100%;
  963. box-sizing: border-box;
  964. .choosedList-cont{
  965. position: relative;
  966. background-color: #fff;
  967. height: calc(100% - 60px);
  968. .choosed-table{
  969. position: relative;
  970. }
  971. .redBg-row{
  972. color: #f5452e;
  973. input{
  974. color: #f5452e;
  975. }
  976. }
  977. .discount-box{
  978. position: absolute;
  979. left: 15px;
  980. bottom: 15px;
  981. .red{
  982. color: #f5452e;
  983. font-size: 14px;
  984. }
  985. }
  986. }
  987. .total-bar{
  988. > div{
  989. text-align: right;
  990. &:first-child{
  991. span{
  992. color: #666;
  993. }
  994. .red{
  995. color: #f5452e;
  996. font-size: 14px;
  997. }
  998. }
  999. &:last-child{
  1000. display: flex;
  1001. align-items: center;
  1002. justify-content: flex-end;
  1003. }
  1004. }
  1005. }
  1006. }
  1007. </style>