edit.vue 42 KB

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