quotedPriceProduct.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <div>
  3. <div >
  4. <el-input
  5. size="small"
  6. style="width: 200px;float: left"
  7. suffix-icon="el-icon-search"
  8. v-model="param.content.where.condition"
  9. placeholder="产品名称,编号"
  10. @keyup.enter.native="productData(param.content.pageNumber = 1)"
  11. @clear="productData(param.content.pageNumber = 1)"
  12. clearable>
  13. </el-input>
  14. <importExcel style="float: right" @onSuccess="onSuccess" v-if="type === '客户报价'" ref="quoterImport" @checkForm="checkFormImport"></importExcel>
  15. <productTable style="float: right;margin-right: 10px;margin-bottom: 10px" :id="sa_projectid" @checkForm="checkForm" ref="quoterPrice" @productAdd="productData"></productTable>
  16. <delProduct style="float: right;margin-right: 10px" :data="selectDel" @delSuccess="delSuccess"></delProduct>
  17. </div>
  18. <div class="produtMag-panel" >
  19. <el-table
  20. ref="multipleTable"
  21. :data="list"
  22. style="width: 100%"
  23. :header-cell-style="{height:'50px',color:'#606266',fontWeight:'400'}"
  24. :cell-style="{height:'50px',color:'#666666',fontWeight:'400'}"
  25. @selection-change="selectionChange">
  26. <el-table-column
  27. type="selection"
  28. width="55">
  29. </el-table-column>
  30. <el-table-column
  31. align="center"
  32. label="产品图"
  33. width="100">
  34. <template slot-scope="scope">
  35. <div v-if="scope.row.attinfos[0]">
  36. <previewImage class="image" :image="scope.row.attinfos[0]" :list="scope.row.attinfos" :deletebtn="false"></previewImage>
  37. </div>
  38. </template>
  39. </el-table-column>
  40. <el-table-column
  41. prop="itemno"
  42. label="产品编号"
  43. width="180">
  44. </el-table-column>
  45. <el-table-column
  46. prop="itemname"
  47. label="产品名称"
  48. width="180">
  49. </el-table-column>
  50. <el-table-column
  51. label="型号/规格"
  52. width="180">
  53. <template slot-scope="scope">
  54. <p><span>{{scope.row.model}}</span>&nbsp;/&nbsp;<span>{{scope.row.spec}}</span></p>
  55. </template>
  56. </el-table-column>
  57. <el-table-column
  58. prop="caliber"
  59. label="口径"
  60. width="180">
  61. <template slot-scope="scope">
  62. <p><span>{{scope.row.caliber?scope.row.caliber:'--'}}</span></p>
  63. </template>
  64. </el-table-column>
  65. <el-table-column
  66. prop="pressure"
  67. label="压力"
  68. width="180">
  69. <template slot-scope="scope">
  70. <p><span>{{scope.row.pressure?scope.row.pressure:'--'}}</span></p>
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. prop="material"
  75. label="材质"
  76. width="180">
  77. <template slot-scope="scope">
  78. <p><span>{{scope.row.material?scope.row.material:'--'}}</span></p>
  79. </template>
  80. </el-table-column>
  81. <el-table-column
  82. prop="brand"
  83. label="品牌"
  84. width="180">
  85. <template slot-scope="scope">
  86. <p v-for="(item,index) in scope.row.brand">
  87. <span style="float: left" v-if="index === scope.row.brand.length -1">{{item?item.brandname+'':'--'}}</span>
  88. <span style="float: left" v-else>{{item?item.brandname+',':'--'}}</span>
  89. </p>
  90. </template>
  91. </el-table-column>
  92. <el-table-column
  93. prop="itemclass"
  94. label="类别"
  95. width="180">
  96. <template slot-scope="scope">
  97. <p v-for="(item,index) in scope.row.itemclass">
  98. <span style="float: left" v-if="index === scope.row.itemclass.length -1">{{item?item.itemclassname+'':'--'}}</span>
  99. <span style="float: left" v-else>{{item?item.itemclassname+',':'--'}}</span>
  100. </p>
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. prop="unitid"
  105. label="计量单位"
  106. width="100">
  107. <template slot-scope="scope">
  108. <el-tag size="mini" type="info" effect="plain">{{scope.row.unitname}}/{{scope.row.axunitname}}</el-tag>
  109. </template>
  110. </el-table-column>
  111. <el-table-column
  112. prop="num"
  113. label="数量"
  114. width="180">
  115. <template slot-scope="scope">
  116. <el-input-number v-model="scope.row.qty" size="mini" :min="1" label="描述文字" @change="onChangeNum(scope.row.qty,scope.row,scope.$index,scope.row.orderaddqty)"></el-input-number>
  117. </template>
  118. </el-table-column>
  119. <el-table-column
  120. prop="marketprice"
  121. label="牌价"
  122. width="100">
  123. <template slot-scope="scope">
  124. <p><span>{{scope.row.marketprice?scope.row.marketprice:'--'}}</span></p>
  125. </template>
  126. </el-table-column>
  127. <el-table-column
  128. prop="discountrate"
  129. label="折扣(%)"
  130. width="100">
  131. <template slot-scope="scope">
  132. <el-input v-model="scope.row.discountrate" size="mini" placeholder="请输入折扣" @change="onChangeDiscountrate(scope.row.discountrate,scope.row,scope.$index)"></el-input>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. prop="price"
  137. label="单价"
  138. width="100">
  139. <template slot-scope="scope">
  140. <el-input v-model="scope.row.price" size="mini" placeholder="请输入单价" @change="onChangePrice(scope.row.price,scope.row,scope.$index)"></el-input>
  141. </template>
  142. </el-table-column>
  143. <el-table-column
  144. prop="amount"
  145. label="金额"
  146. width="100">
  147. <template slot-scope="scope">
  148. <p><span>{{scope.row.amount}}</span></p>
  149. </template>
  150. </el-table-column>
  151. <el-table-column
  152. prop="specialoffer"
  153. label="是否特价"
  154. width="100">
  155. <template slot-scope="scope">
  156. <i class="el-icon-check" v-if="scope.row.specialoffer === 1" style="color: red;font-size: 20px"></i>
  157. </template>
  158. </el-table-column>
  159. <!-- <el-table-column
  160. prop="operation"
  161. label="操作"
  162. width="100">
  163. <template slot-scope="scope">
  164. <el-button size="mini" type="text" @click="deleteProduct(scope.row)">删除</el-button>
  165. </template>
  166. </el-table-column>-->
  167. </el-table>
  168. <div style="height: 35px;margin-top: 20px">
  169. <div style="float: left">总金额:{{ totalPrice }}元</div>
  170. <div style="float: right">
  171. <el-pagination
  172. background
  173. small
  174. style="text-align: right;"
  175. @size-change="handleSizeChange"
  176. @current-change="handleCurrentChange"
  177. :current-page="currentPage"
  178. :page-size="param.content.pageSize"
  179. layout="total, prev, pager, next, jumper"
  180. :total="total">
  181. </el-pagination>
  182. </div>
  183. </div>
  184. </div>
  185. </div>
  186. </template>
  187. <script>
  188. import uploadFile from "@/components/upload/hw_obs_upload";
  189. import previewImage from "@/components/previewImage";
  190. import productTable from '../components/productTable'
  191. import importExcel from '../modules/importQuotedPrice'
  192. import delProduct from "@/SDrpManagement/QuotedPrice/components/delProduct";
  193. export default {
  194. props:["sa_projectid","type"],
  195. name: "quotedPriceProduct",
  196. components:{uploadFile, previewImage,productTable,importExcel,delProduct},
  197. data(){
  198. return {
  199. selectDel:[],
  200. totalPrice:0,
  201. step:1,
  202. tablecols:[],
  203. list:[],
  204. total:0,
  205. currentPage:0,
  206. changeList:[],
  207. sa_quotedpriceid:'',
  208. param:{
  209. "id": 20221021095503,
  210. "version":1,
  211. "content": {
  212. "sa_quotedpriceid":'',
  213. "pageNumber": 1,
  214. "pageSize": 20,
  215. "where": {
  216. "condition": ""
  217. }
  218. }
  219. }
  220. }
  221. },
  222. methods:{
  223. /*/!*产品配置信息新增初始化*!/
  224. async productInitialization(id){
  225. this.param.content.sa_quotedpriceid = id
  226. const res = await this.$api.requested(this.param)
  227. this.list = res.data
  228. this.total = res.total
  229. this.totalPrice = 0
  230. for (var i=0 ;i<this.list.length;i++){
  231. this.list[i].discountrate = this.list[i].discountrate * 100
  232. this.totalPrice = this.totalPrice + this.list[i].qty * this.list[i].price
  233. }
  234. this.$emit("queryTotalPrice",totalPrice)
  235. console.log(this.list,totalPrice,'产品配置信息')
  236. },*/
  237. /*产品配置信息*/
  238. async productData(){
  239. console.log(this.id,"配置信息")
  240. this.param.content.sa_quotedpriceid = this.sa_quotedpriceid
  241. console.log(this.param,"param数据")
  242. const res = await this.$api.requested(this.param)
  243. this.list = res.data
  244. this.total = res.total
  245. this.totalPrice = 0
  246. for (var i=0 ;i<this.list.length;i++){
  247. this.list[i].discountrate = this.list[i].discountrate * 100
  248. this.totalPrice = this.totalPrice + this.list[i].qty * this.list[i].price
  249. }
  250. console.log(this.list,'产品配置信息')
  251. },
  252. /* /!*修改折扣或单价的时候刷新*!/
  253. async productDiscountrateData(id){
  254. this.param.content.sa_quotedpriceid = id
  255. const res = await this.$api.requested(this.param)
  256. this.list = res.data
  257. this.total = res.total
  258. this.totalPrice = 0
  259. for (var i=0 ;i<this.list.length;i++){
  260. this.list[i].discountrate = this.list[i].discountrate * 100
  261. this.totalPrice = this.totalPrice + this.list[i].qty * this.list[i].price
  262. }
  263. console.log(this.list,'产品配置信息')
  264. },*/
  265. handleSizeChange(val) {
  266. // console.log(`每页 ${val} 条`);
  267. this.param.content.pageSize = val
  268. this.productData()
  269. },
  270. handleCurrentChange(val) {
  271. // console.log(`当前页: ${val}`);
  272. this.param.content.pageNumber = val
  273. this.productData()
  274. },
  275. /*批量删除*/
  276. delSuccess(){
  277. this.productData()
  278. },
  279. onSuccess(){
  280. this.productData()
  281. },
  282. clearData(){
  283. this.search = ""
  284. this.param.content.where.condition = this.search
  285. this.productData()
  286. },
  287. queryClick(){
  288. this.param.content.where.condition = this.search
  289. this.productData()
  290. },
  291. selectionChange(val){
  292. console.log(val,'选择')
  293. for (let i=0;i<val.length;i++){
  294. this.selectDel[i] = val[i].sa_quotedprice_itemsid
  295. }
  296. console.log(this.selectDel)
  297. },
  298. checkForm(){
  299. this.$emit('checkForm')
  300. },
  301. checkFormImport(){
  302. this.$emit('checkFormImport')
  303. },
  304. quoterImport(sa_quotedpriceid){
  305. this.sa_quotedpriceid = sa_quotedpriceid
  306. this.$refs.quoterImport.onImport(sa_quotedpriceid)
  307. },
  308. quoterPrice(sa_quotedpriceid,type){
  309. this.sa_quotedpriceid = sa_quotedpriceid
  310. console.log(sa_quotedpriceid,"报价单id")
  311. console.log(type,"项目报价")
  312. this.$refs.quoterPrice.queryProduct(sa_quotedpriceid,type)
  313. },
  314. onChangeNum (val,data,index,step) {
  315. console.log("步长",this.step)
  316. console.log(val,data,index,step)
  317. if (val <= data.orderminqty){
  318. val = data.orderminqty
  319. }else {
  320. val = val - data.orderminqty
  321. let m = val % data.orderaddqty
  322. console.log(m)
  323. if (m !== 0){
  324. val = val + data.orderaddqty
  325. console.log(val,"新的数量值")
  326. data.qty = val
  327. }
  328. }
  329. data.amount = val * data.price
  330. this.$set(this.list,index,data)
  331. this.totalPrice = 0
  332. for (var i=0 ;i<this.list.length;i++){
  333. this.totalPrice = this.totalPrice + this.list[i].qty * this.list[i].price
  334. }
  335. this.$emit('productData',this.list)
  336. },
  337. onChangeDiscountrate(val,data,index) {
  338. console.log(val,data,index)
  339. if (val > 100){
  340. data.discountrate = 100
  341. val = 100
  342. }else if (val <= 10){
  343. data.discountrate = 10
  344. val = 10
  345. }
  346. data.price = data.marketprice * (val / 100)
  347. data.amount = (data.qty * data.price).toFixed(2)
  348. this.$set(this.list,index,data)
  349. this.totalPrice = 0
  350. for (var i=0 ;i<this.list.length;i++){
  351. this.totalPrice = this.totalPrice + this.list[i].qty * this.list[i].price
  352. }
  353. this.$emit('productData',this.list)
  354. },
  355. onChangePrice(val,data,index){
  356. if (val > data.marketprice) {
  357. data.price = data.marketprice
  358. val = data.marketprice
  359. }else if (val < 0){
  360. data.price = data.marketprice * 0.1
  361. val = data.marketprice * 0.1
  362. }
  363. data.discountrate = ((val / data.marketprice) * 100).toFixed(2)
  364. data.amount = data.qty * data.price
  365. this.$set(this.list,index,data)
  366. this.totalPrice = 0
  367. for (var i=0 ;i<this.list.length;i++){
  368. this.totalPrice = this.totalPrice + this.list[i].qty * this.list[i].price
  369. }
  370. this.$emit('productData',this.list)
  371. },
  372. objSet(data){
  373. let obj = data.map(e=>{
  374. return {
  375. sa_quotedprice_itemsid:e.sa_quotedprice_itemsid,
  376. itemid:e.itemid,
  377. oldprice:e.marketprice,
  378. price:e.price,
  379. discountrate:0,
  380. qty:e.qty
  381. }
  382. })
  383. this.changeDiscountrateData(obj)
  384. },
  385. async changeData(obj){
  386. console.log(this.list,"数据")
  387. const res = await this.$api.requested({
  388. "id": 20221021095403,
  389. "version":1,
  390. "content": {
  391. "sa_quotedpriceid":this.list[0].sa_quotedpriceid, //sat_notice_classid<=0时 为新增
  392. "items":obj
  393. }
  394. })
  395. console.log(res)
  396. this.productData(res.data[0].sa_quotedpriceid)
  397. },
  398. async changeDiscountrateData(obj){
  399. console.log(this.list,"数据")
  400. const res = await this.$api.requested({
  401. "id": 20221021095403,
  402. "version":1,
  403. "content": {
  404. "sa_quotedpriceid":this.list[0].sa_quotedpriceid, //sat_notice_classid<=0时 为新增
  405. "items":obj
  406. }
  407. })
  408. console.log(res)
  409. this.productDiscountrateData(res.data[0].sa_quotedpriceid)
  410. },
  411. async deleteProduct(val){
  412. console.log(val)
  413. const res = await this.$api.requested({
  414. "id": 20221021095603,
  415. "version":1,
  416. "content": {
  417. "sa_quotedprice_itemsids":[val.sa_quotedprice_itemsid] //sat_notice_classid<=0时 为新增
  418. }
  419. })
  420. this.tool.showMessage(res,()=>{
  421. this.productData(val.sa_quotedpriceid)
  422. })
  423. }
  424. },
  425. mounted() {
  426. this.productData()
  427. }
  428. }
  429. </script>
  430. <style scoped>
  431. .produtMag-panel{
  432. margin-top: 15px;
  433. background: #fff;
  434. border-radius:5px;
  435. border:1px solid rgb(0 0 0 / 5%)
  436. /* box-shadow: 0 5px 5px rgb(0 0 0 / 10%);
  437. transform: translate3d(0,-2px,0); */
  438. }
  439. .image {
  440. width:38px;height:38px;margin:0px auto;
  441. }
  442. </style>