productInventory.vue 13 KB

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