edit.vue 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044
  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. :sourceType="detailData.sourceType"
  308. @viewRecord="hanldSalesRecord"
  309. @close="openChooseProduct=false"
  310. @add="insterProduct"
  311. ></chooseProductModal>
  312. <!-- 选择货架产品 -->
  313. <chooseShelfProduct
  314. v-if="showShelfModal"
  315. ref="chooseShelfProduct"
  316. @viewRecord="hanldSalesRecord"
  317. @add="insterProduct"
  318. @plAdd="plInsterProduct"
  319. :baseData="shelfInfo"
  320. :openModal="showShelfModal"
  321. @close="showShelfModal=false"></chooseShelfProduct>
  322. </div>
  323. </template>
  324. <script>
  325. import { commonMixin } from '@/utils/mixin'
  326. import { mapActions } from 'vuex'
  327. import { Empty } from 'ant-design-vue'
  328. import { hdPrint } from '@/libs/JGPrint'
  329. // 组件
  330. import { STable, VSelect } from '@/components'
  331. import outInDetialModal from './outInDetialModal.vue'
  332. import chooseShelfProduct from './chooseShelfProduct.vue'
  333. import PrintPanel from '@/views/common/printPanel.vue'
  334. import chooseProductModal from './chooseProductModal.vue'
  335. import chooseCustomModal from './chooseCustomModal.vue'
  336. import importGuideModal from './importGuideModal.vue'
  337. import settleModal from '@/views/financialManagement/settleModal/settleModal.vue'
  338. import productSalesRecordModal from './productSalesRecordModal.vue'
  339. // 接口
  340. import { stockByProductSn } from '@/api/stock'
  341. import { queryByCustomerSn } from '@/api/shelf'
  342. import { salesDetail, salesWriteSubmit, salesWriteDiscount, salesDetailPrint, salesDetailExport, salesDel } from '@/api/sales'
  343. import { salesDetailList, salesDetailInsert, salesDetailInsertBatch, salesDetailUpdatePrice, salesDetailUpdateQty, salesDetailDel, salesDetailInsertImport, queryCheckedList } from '@/api/salesDetail'
  344. export default {
  345. name: 'SalesEdit',
  346. components: { STable, VSelect, chooseProductModal, chooseCustomModal, PrintPanel, importGuideModal, settleModal, outInDetialModal, chooseShelfProduct, productSalesRecordModal },
  347. mixins: [commonMixin],
  348. data () {
  349. return {
  350. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE, // 默认空图片
  351. tableHeight: 0, // 表格高度
  352. showOutInModal: false, // 出入库明细
  353. showCell: false, // 显示列下拉选项
  354. showPage: false, // 是否显示组件
  355. spinning: false,
  356. showSearch: false, // 是否显示查询条件
  357. openChooseProduct: false, // 是否显示产品列表弹框
  358. orderId: null, // 销售单id
  359. salesBillSn: null, // 销售单sn
  360. disabled: false, // 查询、重置按钮是否可操作
  361. isInster: false, // 是否正在添加产品
  362. openModal: false, // 客户弹框
  363. openSalesRecordModal: false, // 销售记录
  364. openGuideModal: false, // 导入产品弹框
  365. openSettleModal: false, // 打开收款弹框
  366. enableFundAccount: false, // 是否开启资金账户管理
  367. showShelfModal: false, // 货架产品弹框
  368. checkedProductList: [], // 已选所有产品
  369. delLoading: false, // 按钮loading
  370. detailData: { discountAmount: 0, id: null, salesBillSn: '' }, // 订单基础数据
  371. dataSource: [], // 原始数据
  372. productForm: {
  373. productName: '', // 产品名称
  374. productCode: '', // 产品编码
  375. oosFlag: undefined, // 是否急件
  376. orderBy: 'sales_bill_detail.CREATE_DATE desc' // 排序
  377. },
  378. tbForm: [], // 同步操作选项值
  379. printOrgCode: false, // 是否打印原创编码
  380. printAllName: false, // 是否打印全部名称
  381. printRemarks: false, // 是否打印备注
  382. printNo: true, // 是否打印销售单号
  383. printPrice: false, // 是否打印价格
  384. // 加载数据方法 必须为 Promise 对象
  385. loadData: parameter => {
  386. this.disabled = true
  387. this.spinning = true
  388. this.productForm.salesBillSn = this.$route.params.sn
  389. this.getChoosedList({ salesBillSn: this.$route.params.sn })
  390. return salesDetailList(Object.assign(parameter, this.productForm)).then(res => {
  391. let data
  392. if (res.status == 200) {
  393. data = res.data
  394. const no = (data.pageNo - 1) * data.pageSize
  395. for (var i = 0; i < data.list.length; i++) {
  396. data.list[i].no = no + i + 1
  397. // 缓存数量和价格
  398. data.list[i].qtyBackups = data.list[i].qty
  399. data.list[i].priceBackups = data.list[i].price
  400. }
  401. this.disabled = false
  402. this.dataSource = data.list || []
  403. }
  404. this.spinning = false
  405. return data
  406. })
  407. },
  408. printerType: 'NEEDLE', // 打印机类型
  409. isCosts: false, // 是否显示成本价
  410. shelfInfo: null, // 是否有货架
  411. discountAmountBak: null // 折扣备份数据
  412. }
  413. },
  414. computed: {
  415. // 是否自建单据
  416. isOwerEdit () {
  417. return this.detailData && this.detailData.sourceType == 'SALES'
  418. },
  419. // 是否审核通过
  420. isAudit () {
  421. return this.detailData && (this.detailData.billStatus == 'WAIT_OUT_WAREHOUSE' || this.detailData.billStatus == 'FINISH')
  422. },
  423. // 列定义
  424. columns () {
  425. const _this = this
  426. const arr = [
  427. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  428. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '11%', scopedSlots: { customRender: 'productCode' }, align: 'center' },
  429. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '15%', align: 'left', scopedSlots: { customRender: 'productName' }, ellipsis: true },
  430. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  431. { title: '品牌', dataIndex: 'dealerProductEntity.productBrandName', width: '8%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  432. // { title: '仓库', dataIndex: 'warehouseEntity.name', width: '8%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  433. // { title: '仓位', dataIndex: 'warehouseLocationEntity.name', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  434. { title: '售价', dataIndex: 'price', scopedSlots: { customRender: 'price' }, width: '7%', align: 'center' },
  435. { title: '销售数量', scopedSlots: { customRender: 'salesNums' }, width: '7%', align: 'center' },
  436. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  437. { title: '售价小计', dataIndex: 'totalAmount', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  438. { title: '折后小计', dataIndex: 'discountedAmount', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  439. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  440. ]
  441. // 下级创建,不显示仓库仓位
  442. if (!this.isOwerEdit) {
  443. arr.splice(7, 0, { title: '库存数量', dataIndex: 'currentStockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  444. } else {
  445. arr.splice(5, 0, { title: '仓库', dataIndex: 'warehouseEntity.name', width: '8%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } })
  446. arr.splice(6, 0, { title: '仓位', dataIndex: 'warehouseLocationEntity.name', width: '8%', align: 'center', customRender: function (text) { return text || '--' } })
  447. }
  448. if (this.detailData && this.detailData.sourceType && this.detailData.sourceType === 'XPRH_PURCHASE') {
  449. 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) : '--') } })
  450. }
  451. // 实际总成本
  452. if (this.isCosts) {
  453. 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) : '--') } })
  454. }
  455. return arr
  456. }
  457. },
  458. methods: {
  459. ...mapActions(['GetSettleAccountState']),
  460. // 更多操作
  461. handleActions (e) {
  462. // 导入产品
  463. if (e.key == 4) {
  464. this.openGuideModal = true
  465. }
  466. // 货架产品
  467. if (e.key == 3) {
  468. this.showShelfModal = true
  469. }
  470. if (e.key == 2) { // 清空列表
  471. this.delSalerOrder()
  472. }
  473. if (e.key == 1) { // 删除急件
  474. this.delSalerOrder(this.isOwerEdit ? 1 : 2)
  475. }
  476. },
  477. // 打印预览/快捷打印
  478. handlePrint (type, printerType) {
  479. const _this = this
  480. _this.spinning = true
  481. let url = salesDetailPrint
  482. const params = {
  483. sn: this.outBizSn || this.$route.params.sn,
  484. printOrgCode: this.printOrgCode ? 1 : 0,
  485. printAllName: this.printAllName ? 1 : 0,
  486. remarksShowFlag: this.printRemarks ? 1 : 0,
  487. printNo: this.printNo ? 1 : 0,
  488. priceFlag: this.printPrice ? 1 : 0
  489. }
  490. if (type == 'export') { // 导出
  491. url = salesDetailExport
  492. }
  493. // 打印或导出
  494. hdPrint(printerType, type, url, params, '销售单', function () {
  495. _this.spinning = false
  496. _this.$refs.printBox.hovered = false
  497. })
  498. },
  499. // 选择同步操作选项
  500. tbFormChange (e, val) {
  501. this.tbForm = []
  502. const tbTypes = ['AUDIT', 'STOCK_OUT', 'SETTLE']
  503. if (e.target.checked) {
  504. for (let i = val; i >= 0; i--) {
  505. this.tbForm.push(tbTypes[i])
  506. }
  507. } else {
  508. this.tbForm = []
  509. }
  510. },
  511. // 编辑客户信息
  512. handleEdit () {
  513. this.openModal = true
  514. this.$refs.custModal.editCust(this.detailData)
  515. },
  516. // 查看销售记录
  517. hanldSalesRecord (row) {
  518. console.log(row)
  519. this.openSalesRecordModal = true
  520. this.$refs.salseRecord.getDetail(this.detailData.buyerSn, row.productSn, row)
  521. },
  522. // 查询已选所以产品
  523. getChoosedList (params) {
  524. this.isInster = true
  525. queryCheckedList(params).then(res => {
  526. this.checkedProductList = res.data || []
  527. this.isInster = false
  528. })
  529. },
  530. // 更新产品列表
  531. updateData (priceType) {
  532. // 价格类型变更
  533. if (priceType != this.$route.params.priceType) {
  534. this.getOrderDetail(true)
  535. this.$router.push({ name: 'salesNewEdit', params: { id: this.orderId, sn: this.salesBillSn, priceType: priceType } })
  536. } else {
  537. this.getOrderDetail(true)
  538. }
  539. },
  540. // 非下级创建的单据,修改数量时校验库存
  541. validStock (val, record) {
  542. const _this = this
  543. this.spinning = true
  544. // 校验库存
  545. stockByProductSn({ productSn: record.productSn }).then(res => {
  546. if (res.status == 200) {
  547. if (res.data && (!res.data.currentStockQty || val <= res.data.currentStockQty)) {
  548. _this.changeQty(record)
  549. } else {
  550. this.$confirm({
  551. title: '提示',
  552. content: '库存不足,确认添加为急件吗?',
  553. centered: true,
  554. closable: true,
  555. onOk () {
  556. _this.changeQty(record)
  557. },
  558. onCancel () {
  559. record.qty = record.qtyBackups
  560. _this.spinning = false
  561. }
  562. })
  563. }
  564. } else {
  565. this.spinning = false
  566. record.qty = record.qtyBackups
  567. }
  568. })
  569. },
  570. // 修改已选产品数量
  571. changeQty (record) {
  572. salesDetailUpdateQty({
  573. id: record.id,
  574. salesBillSn: record.salesBillSn,
  575. productSn: record.productSn,
  576. salesBillDetailSn: record.salesBillDetailSn,
  577. qty: record.qty,
  578. price: record.price
  579. }).then(res => {
  580. this.getOrderDetail(false, true)
  581. if (res.status == 200) {
  582. this.$message.info(res.message)
  583. }
  584. this.spinning = false
  585. })
  586. },
  587. // 已选产品 销售数量 input 输入框 blur
  588. qtyBlur (val, record) {
  589. this.dataSource = record || []
  590. if (val && val != record.qtyBackups) {
  591. // 自建的单据,修改数量时校验库存
  592. if (this.isOwerEdit) {
  593. this.validStock(val, record)
  594. } else {
  595. this.changeQty(record)
  596. }
  597. } else {
  598. record.qty = record.qtyBackups
  599. }
  600. },
  601. // 已选产品 售价 input 输入框 blur
  602. priceBlur (val, record) {
  603. this.dataSource = record || []
  604. // 光标移出,值发生改变再调用编辑接口
  605. if (val && val != record.priceBackups) {
  606. this.spinning = true
  607. salesDetailUpdatePrice({
  608. id: record.id,
  609. salesBillSn: record.salesBillSn,
  610. productSn: record.productSn,
  611. salesBillDetailSn: record.salesBillDetailSn,
  612. qty: record.qty,
  613. price: record.price
  614. }).then(res => {
  615. this.getOrderDetail(false, true)
  616. if (res.status == 200) {
  617. this.$message.info(res.message)
  618. this.spinning = false
  619. } else {
  620. this.spinning = false
  621. }
  622. })
  623. } else {
  624. record.price = record.priceBackups
  625. }
  626. },
  627. // 重置列表
  628. resetForm () {
  629. this.productForm = {
  630. productName: '',
  631. productCode: '',
  632. oosFlag: undefined,
  633. orderBy: 'sales_bill_detail.CREATE_DATE desc'
  634. }
  635. this.$nextTick(() => {
  636. this.$refs.table.refresh()
  637. })
  638. },
  639. // 返回
  640. handleBack () {
  641. this.$router.push({ name: 'salesNewList' })
  642. },
  643. // 打折
  644. salesDiscount () {
  645. if (this.discountAmountBak == this.detailData.discountAmount) {
  646. return false
  647. }
  648. this.spinning = true
  649. salesWriteDiscount({
  650. discountAmount: this.detailData.discountAmount || 0,
  651. salesBillSn: this.detailData.salesBillSn,
  652. id: this.detailData.id
  653. }).then(res => {
  654. if (res.status == 200) {
  655. this.getOrderDetail(true)
  656. } else {
  657. this.spinning = false
  658. }
  659. })
  660. },
  661. // 清空已选产品
  662. delSalerOrder (flag) {
  663. const _this = this
  664. this.$confirm({
  665. title: '提示',
  666. content: !flag ? '确认要清空已选产品列表吗?' : (flag == 1 ? '确认要删除所有急件吗?删除后不可恢复。' : '确认要删除所有缺货吗?删除后不可恢复。'),
  667. centered: true,
  668. closable: true,
  669. onOk () {
  670. _this.spinning = true
  671. const params = { id: _this.orderId, oosFlag: !flag ? undefined : 1 }
  672. salesDel(params).then(res => {
  673. if (res.status == 200) {
  674. _this.getOrderDetail(true)
  675. if (!flag) {
  676. _this.dataSource = []
  677. }
  678. _this.$message.success(res.message)
  679. }
  680. _this.spinning = false
  681. })
  682. }
  683. })
  684. },
  685. // 出入库明细
  686. handleViewDetail (row) {
  687. this.showOutInModal = true
  688. this.$refs.outInDetialModal.getData(row)
  689. },
  690. // 删除产品
  691. handleDel (row) {
  692. const _this = this
  693. this.$confirm({
  694. title: '提示',
  695. content: '确认要删除吗?',
  696. centered: true,
  697. closable: true,
  698. onOk () {
  699. _this.delLoading = true
  700. _this.spinning = true
  701. salesDetailDel({ id: row.id }).then(res => {
  702. if (res.status == 200) {
  703. // 更新详情
  704. _this.getOrderDetail(false, true)
  705. }
  706. _this.$message.info(res.message)
  707. _this.delLoading = false
  708. _this.spinning = false
  709. })
  710. }
  711. })
  712. },
  713. // 添加产品
  714. insterProduct (row) {
  715. // 防止多次添加产品
  716. if (this.isInster) { return }
  717. const _this = this
  718. // 自建的单据显示库存不足时
  719. if (row.currentQty < row.salesNums && this.isOwerEdit) {
  720. _this.$confirm({
  721. title: '提示',
  722. content: '库存不足,确认添加为急件吗?',
  723. centered: true,
  724. closable: true,
  725. onOk () {
  726. _this.isPutCostDyPrice(row)
  727. }
  728. })
  729. } else {
  730. _this.isPutCostDyPrice(row)
  731. }
  732. },
  733. // 判断售价低于成本价
  734. isPutCostDyPrice (row) {
  735. const _this = this
  736. if (row.putCost > row.price) {
  737. // 销售价低于成本价
  738. _this.$confirm({
  739. title: '提示',
  740. content: '售价低于成本价,确认要添加吗?',
  741. centered: true,
  742. closable: true,
  743. onOk () {
  744. _this.saveNewProduct(row)
  745. }
  746. })
  747. } else {
  748. _this.saveNewProduct(row)
  749. }
  750. },
  751. // 保存添加的产品到销售列表
  752. saveNewProduct (row) {
  753. this.$message.loading('正在添加产品...', 1)
  754. this.isInster = true
  755. // this.spinning = true
  756. salesDetailInsert({
  757. buyerSn: this.detailData.buyerSn,
  758. productSn: row.productSn,
  759. cost: row.putCost,
  760. // productCode: row.productCode,
  761. // productOrigCode: row.productOrigCode,
  762. price: row.price,
  763. priceLevel: row.priceLevel,
  764. qty: row.salesNums,
  765. salesBillSn: this.detailData.salesBillSn,
  766. salesBillNo: this.detailData.salesBillNo,
  767. warehouseSn: row.warehouseSn,
  768. warehouseLocationSn: row.warehouseLocationSn,
  769. stockSn: row.stockSn
  770. }).then(res => {
  771. if (res.status == 200) {
  772. this.getOrderDetail(true)
  773. if (this.showShelfModal) {
  774. this.$refs.chooseShelfProduct.reload()
  775. }
  776. } else {
  777. if (res.errCode == 'VALID_F_00001') {
  778. this.productForm = {
  779. productName: '',
  780. productCode: row.productCode || '',
  781. orderBy: 'sales_bill_detail.CREATE_DATE desc'
  782. }
  783. this.showSearch = true
  784. this.$refs.table.refresh(true)
  785. }
  786. this.isInster = false
  787. }
  788. // this.spinning = false
  789. })
  790. },
  791. // 批量添加接口
  792. plInsterProduct (list) {
  793. const params = []
  794. list.map(item => {
  795. params.push({
  796. buyerSn: this.detailData.buyerSn,
  797. productSn: item.productSn,
  798. cost: item.putCost,
  799. price: item.price,
  800. priceLevel: item.priceLevel,
  801. qty: item.salesNums,
  802. salesBillSn: this.detailData.salesBillSn,
  803. salesBillNo: this.detailData.salesBillNo,
  804. stockSn: item.stockSn
  805. })
  806. })
  807. this.$message.loading('正在批量添加产品...', 1)
  808. salesDetailInsertBatch(params).then(res => {
  809. if (res.status == 200) {
  810. this.getOrderDetail(true)
  811. if (this.showShelfModal) {
  812. this.$refs.chooseShelfProduct.reload()
  813. }
  814. }
  815. })
  816. },
  817. // 销售单详情
  818. getOrderDetail (flag, resetTable) {
  819. const vm = this
  820. vm.spinning = true
  821. salesDetail({ id: vm.$route.params.id }).then(res => {
  822. if (res.status == 200) {
  823. vm.detailData = res.data
  824. vm.discountAmountBak = vm.detailData.discountAmount
  825. if (res.data.delFlag == 1) {
  826. vm.$message.info('该销售单已删除')
  827. vm.handleBack()
  828. return false
  829. }
  830. if (flag) {
  831. const buyerSn = (vm.detailData && vm.detailData.buyerSn && vm.detailData.sourceType && vm.detailData.sourceType == 'PURCHASE') ? '' : vm.detailData.buyerSn
  832. const priceType = vm.$route.params.priceType
  833. vm.$refs.partQuery.pageInit(buyerSn, priceType, vm.salesBillSn)
  834. if (vm.detailData.totalCategory) {
  835. vm.resetForm()
  836. } else {
  837. vm.spinning = false
  838. vm.checkedProductList = []
  839. }
  840. // 查询关联的客户货架信息
  841. if (vm.detailData && vm.detailData.buyerSn) {
  842. vm.getShelfQueryByCustomer()
  843. }
  844. } else {
  845. if (resetTable) {
  846. vm.$refs.table.refresh()
  847. } else {
  848. vm.spinning = false
  849. }
  850. }
  851. }
  852. })
  853. },
  854. // 查询关联的客户货架信息
  855. getShelfQueryByCustomer () {
  856. queryByCustomerSn({ sn: this.detailData.buyerSn }).then(res => {
  857. if (res.data) {
  858. this.shelfInfo = Object.assign(res.data, { salePriceType: this.$route.params.priceType, salesBillSn: this.salesBillSn })
  859. } else {
  860. this.shelfInfo = null
  861. }
  862. })
  863. },
  864. // 提交销售单
  865. handleSubmit (params) {
  866. this.spinning = true
  867. const submitTypes = this.tbForm.join(',')
  868. salesWriteSubmit({ id: this.orderId, submitTypes: submitTypes, ...params }).then(res => {
  869. if (res.status == 200) {
  870. this.handleBack()
  871. this.$message.success(res.message)
  872. this.spinning = false
  873. } else {
  874. this.spinning = false
  875. }
  876. })
  877. },
  878. // 开启结算账户功能收款, type:0 单条收款,1 批量收款
  879. handleSettleAcountPay (row, type) {
  880. this.openSettleModal = true
  881. const data = {
  882. totalAmount: this.detailData.discountedAmount,
  883. settleClientName: '',
  884. title: '收款',
  885. type,
  886. row
  887. }
  888. this.$nextTick(() => {
  889. this.$refs.settleModal.setData(data)
  890. })
  891. },
  892. // 去收款
  893. settleAcountPay (form, data) {
  894. const params = {}
  895. // 资金管理开启
  896. if (this.enableFundAccount) {
  897. params.settleStyleSn = form.settleStyleSn
  898. params.settleAccountSn = form.settleAccountSn
  899. }
  900. this.spinning = true
  901. this.handleSubmit(params)
  902. },
  903. // 确认导入明细
  904. hanldeImprotOk (obj) {
  905. this.spinning = true
  906. salesDetailInsertImport(obj).then(res => {
  907. if (res.status == 200) {
  908. this.getOrderDetail(true)
  909. }
  910. this.spinning = false
  911. })
  912. },
  913. // 计算表格高度
  914. setTableH () {
  915. this.tableHeight = window.innerHeight - (this.showSearch ? 42 : 0) - 300
  916. },
  917. // 页面初始话
  918. pageInit () {
  919. const vm = this
  920. vm.$nextTick(() => {
  921. vm.setTableH()
  922. vm.orderId = vm.$route.params.id
  923. vm.salesBillSn = vm.$route.params.sn
  924. // 是否默认打印原厂编码
  925. vm.printOrgCode = localStorage.getItem('printOrgCode-' + this.$store.state.user.info.orgId) == 'true'
  926. vm.printAllName = localStorage.getItem('printAllName-' + this.$store.state.user.info.orgId) == 'true'
  927. vm.printRemarks = localStorage.getItem('printRemarks-' + this.$store.state.user.info.orgId) == 'true'
  928. vm.printPrice = localStorage.getItem('printPrice-' + this.$store.state.user.info.orgId) == 'true'
  929. const printNo = localStorage.getItem('printNo-' + this.$store.state.user.info.orgId)
  930. vm.printNo = printNo ? printNo == 'true' : true
  931. // 获取详情
  932. vm.getOrderDetail(true)
  933. })
  934. }
  935. },
  936. watch: {
  937. // 打印选项缓存
  938. printOrgCode (newValue, oldValue) {
  939. localStorage.setItem('printOrgCode-' + this.$store.state.user.info.orgId, newValue)
  940. },
  941. printAllName (newValue, oldValue) {
  942. localStorage.setItem('printAllName-' + this.$store.state.user.info.orgId, newValue)
  943. },
  944. printPrice (newValue, oldValue) {
  945. localStorage.setItem('printPrice-' + this.$store.state.user.info.orgId, newValue)
  946. },
  947. printRemarks (newValue, oldValue) {
  948. localStorage.setItem('printRemarks-' + this.$store.state.user.info.orgId, newValue)
  949. },
  950. printNo (newValue, oldValue) {
  951. localStorage.setItem('printNo-' + this.$store.state.user.info.orgId, newValue)
  952. },
  953. showSearch (newValue, oldValue) {
  954. this.setTableH()
  955. },
  956. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  957. this.setTableH()
  958. }
  959. },
  960. mounted () {
  961. this.showPage = true
  962. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  963. this.pageInit()
  964. }
  965. },
  966. activated () {
  967. this.showPage = true
  968. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  969. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  970. this.pageInit()
  971. }
  972. // 结算账户状态查询
  973. if (this.$hasPermissions('M_fundAccountList') && this.$hasPermissions('B_fundAccountEnable')) {
  974. this.GetSettleAccountState().then(res => {
  975. if (res.status == 200) {
  976. this.enableFundAccount = res.data.functionEnableFlag == 1
  977. }
  978. })
  979. }
  980. },
  981. beforeRouteEnter (to, from, next) {
  982. next(vm => {})
  983. }
  984. }
  985. </script>
  986. <style lang="less">
  987. .salesEdit-news-wrap{
  988. position: relative;
  989. height: 100%;
  990. box-sizing: border-box;
  991. .choosedList-cont{
  992. position: relative;
  993. background-color: #fff;
  994. height: calc(100% - 60px);
  995. .choosed-table{
  996. position: relative;
  997. }
  998. .redBg-row{
  999. color: #f5452e;
  1000. input{
  1001. color: #f5452e;
  1002. }
  1003. }
  1004. .discount-box{
  1005. position: absolute;
  1006. left: 15px;
  1007. bottom: 15px;
  1008. .red{
  1009. color: #f5452e;
  1010. font-size: 14px;
  1011. }
  1012. }
  1013. }
  1014. .total-bar{
  1015. > div{
  1016. text-align: right;
  1017. &:first-child{
  1018. span{
  1019. color: #666;
  1020. }
  1021. .red{
  1022. color: #f5452e;
  1023. font-size: 14px;
  1024. }
  1025. }
  1026. &:last-child{
  1027. display: flex;
  1028. align-items: center;
  1029. justify-content: flex-end;
  1030. }
  1031. }
  1032. }
  1033. }
  1034. </style>