productTable.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div>
  3. <el-button size="small" type="primary" icon="el-icon-plus" @click="onShow">添加商品</el-button>
  4. <el-drawer
  5. title="选择商品"
  6. :visible.sync="dialogProductVisible"
  7. append-to-body
  8. size="80%"
  9. direction="rtl"
  10. @close="onColes">
  11. <div class="drawer__panel">
  12. <div class="flex-align-center flex-between ">
  13. <slot name="operation"></slot>
  14. <div class="flex-align-center">
  15. <el-input size="small" suffix-icon="el-icon-search" v-model="params.content.where.condition" placeholder="产品名称,编号" @keyup.enter.native="productData(params.content.pageNumber = 1)" @clear="productData(params.content.pageNumber = 1)" clearable></el-input>&nbsp;
  16. </div>
  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:'#768093',fontWeight:'100'}"
  24. :cell-style="{height:'50px',color:'#768093',fontWeight:'200'}"
  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="80">
  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. </el-table-column>
  62. <el-table-column
  63. prop="pressure"
  64. label="压力"
  65. width="180">
  66. </el-table-column>
  67. <el-table-column
  68. prop="material"
  69. label="材质"
  70. width="180">
  71. </el-table-column>
  72. <el-table-column
  73. prop="brand"
  74. label="品牌"
  75. width="180">
  76. <template slot-scope="scope">
  77. <p v-for="(item,index) in scope.row.brand">
  78. <span style="float: left" v-if="index === scope.row.brand.length -1">{{item?item.brandname+'':'--'}}</span>
  79. <span style="float: left" v-else>{{item?item.brandname+',':'--'}}</span>
  80. </p>
  81. </template>
  82. </el-table-column>
  83. <el-table-column
  84. prop="itemclass"
  85. label="类别"
  86. width="180">
  87. <template slot-scope="scope">
  88. <p v-for="(item,index) in scope.row.itemclass">
  89. <span style="float: left" v-if="index === scope.row.itemclass.length -1">{{item?item.itemclassname+'':'--'}}</span>
  90. <span style="float: left" v-else>{{item?item.itemclassname+',':'--'}}</span>
  91. </p>
  92. </template>
  93. </el-table-column>
  94. <el-table-column
  95. prop="unitid"
  96. label="计量单位"
  97. width="100">
  98. <template slot-scope="scope">
  99. <el-tag size="mini" type="info" effect="plain">{{scope.row.unitname}}/{{scope.row.axunitname}}</el-tag>
  100. </template>
  101. </el-table-column>
  102. <el-table-column
  103. prop="marketprice"
  104. label="牌价"
  105. width="100">
  106. <template slot-scope="scope">
  107. <span >{{scope.row.marketprice?scope.row.marketprice+',':'--'}}</span>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. <div style="margin-top:16px;text-align:right">
  112. <el-pagination
  113. background
  114. small
  115. @size-change="handleSizeChange"
  116. @current-change="handleCurrentChange"
  117. :current-page="currentPage"
  118. :page-size="params.content.pageSize"
  119. layout="total, prev, pager, next, jumper"
  120. :total="total">
  121. </el-pagination>
  122. </div>
  123. </div>
  124. </div>
  125. <div class="fixed__btn__panel">
  126. <el-button size="small" @click="onColes" class="normal-btn-width">取 消</el-button>
  127. <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>
  128. </div>
  129. </el-drawer>
  130. </div>
  131. </template>
  132. <script>
  133. import uploadFile from "@/components/upload/hw_obs_upload";
  134. import previewImage from "@/components/previewImage";
  135. export default {
  136. name: "productTable",
  137. props:["id"],
  138. components:{uploadFile, previewImage},
  139. data(){
  140. return {
  141. dialogProductVisible:false,
  142. type:'',
  143. tablecols:[],
  144. list:[],
  145. total:0,
  146. currentPage:0,
  147. tableSelectData:[],
  148. selectData:[],
  149. params:{
  150. "id": 20221020164903,
  151. "version":1,
  152. "content": {
  153. "sa_projectid":'',
  154. "sa_quotedpriceid":"",
  155. "pageNumber": 1,
  156. "pageSize": 20,
  157. "where": {
  158. "condition": ""
  159. }
  160. }
  161. }
  162. }
  163. },
  164. methods:{
  165. onShow(){
  166. /* this.dialogProjectVisible = true*/
  167. console.log(this.id,"项目编号")
  168. this.$emit('checkForm')
  169. /*this.productData()*/
  170. },
  171. onColes(){
  172. this.dialogProductVisible = false
  173. },
  174. async onSubmit(){
  175. const res = await this.$api.requested({
  176. "id": 20221021095403,
  177. "version":1,
  178. "content": {
  179. "sa_quotedpriceid":this.params.content.sa_quotedpriceid, //sat_notice_classid<=0时 为新增
  180. "items":this.selectData
  181. }
  182. })
  183. this.tool.showMessage(res,()=>{
  184. console.log(res)
  185. this.dialogProductVisible = false
  186. this.$emit('productAdd',this.params.content.sa_quotedpriceid)
  187. })
  188. },
  189. /*获取产品信息*/
  190. queryProduct(id,type){
  191. this.dialogProductVisible = true
  192. this.params.content.sa_projectid = this.id
  193. console.log(id,"报价单id五")
  194. this.type = type
  195. this.productData(id)
  196. },
  197. /*产品配置信息*/
  198. async productData(id){
  199. console.log("执行")
  200. console.log(id,"报价单id四")
  201. this.params.content.sa_quotedpriceid = id
  202. const res = await this.$api.requested(this.params)
  203. this.list = res.data
  204. this.total = res.total
  205. console.log(res,'产品配置信息')
  206. this.$nextTick(()=>{
  207. for (let i=0;i<this.list.length;i++){
  208. this.$refs.multipleTable.toggleRowSelection(this.list[i],true)
  209. }
  210. })
  211. },
  212. handleSizeChange(val) {
  213. // console.log(`每页 ${val} 条`);
  214. this.param.content.pageSize = val
  215. this.productData()
  216. },
  217. handleCurrentChange(val) {
  218. // console.log(`当前页: ${val}`);
  219. this.param.content.pageNumber = val
  220. this.productData()
  221. },
  222. onSuccess(){
  223. this.productData()
  224. },
  225. clearData(){
  226. console.log("执行")
  227. this.search = ""
  228. this.param.content.where.condition = this.search
  229. this.productData()
  230. },
  231. queryClick(){
  232. this.param.content.where.condition = this.search
  233. this.productData()
  234. },
  235. selectionChange(val){
  236. console.log(val)
  237. this.tableSelectData = val
  238. if (this.type === '项目报价'){
  239. let obj = this.tableSelectData.map(e=>{
  240. return {
  241. sa_quotedprice_itemsid:'0',
  242. itemid:e.itemid,
  243. oldprice:0,
  244. price:e.price,
  245. discountrate:50,
  246. qty:e.qty
  247. }
  248. })
  249. console.log(obj)
  250. this.selectData = obj
  251. }else {
  252. let obj = this.tableSelectData.map(e=>{
  253. return {
  254. sa_quotedprice_itemsid:'0',
  255. itemid:e.itemid,
  256. oldprice:0,
  257. price:e.price,
  258. discountrate:50,
  259. qty:1
  260. }
  261. })
  262. console.log(obj)
  263. this.selectData = obj
  264. }
  265. }
  266. },
  267. mounted() {
  268. }
  269. }
  270. </script>
  271. <style scoped>
  272. .image {
  273. width:40px;height:40px;margin:0px auto;
  274. }
  275. </style>