productTable.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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="0">
  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. sa_quotedpriceid:'',
  150. params:{
  151. "id": 20221020164903,
  152. "version":1,
  153. "content": {
  154. "sa_projectid":'',
  155. "sa_quotedpriceid":"",
  156. "pageNumber": 1,
  157. "pageSize": 20,
  158. "where": {
  159. "condition": ""
  160. }
  161. }
  162. }
  163. }
  164. },
  165. methods:{
  166. onShow(){
  167. /* this.dialogProjectVisible = true*/
  168. console.log(this.id,"项目编号")
  169. this.$emit('checkForm')
  170. /*this.productData()*/
  171. },
  172. onColes(){
  173. this.dialogProductVisible = false
  174. },
  175. async onSubmit(){
  176. const res = await this.$api.requested({
  177. "id": 20221021095403,
  178. "version":1,
  179. "content": {
  180. "sa_quotedpriceid":this.params.content.sa_quotedpriceid, //sat_notice_classid<=0时 为新增
  181. "items":this.selectData
  182. }
  183. })
  184. this.tool.showMessage(res,()=>{
  185. console.log(res)
  186. this.dialogProductVisible = false
  187. this.$emit('productAdd',this.params.content.sa_quotedpriceid)
  188. })
  189. },
  190. /*获取产品信息*/
  191. queryProduct(id,type){
  192. console.log(id,type)
  193. this.dialogProductVisible = true
  194. this.params.content.sa_projectid = this.id
  195. console.log(id,"报价单id五")
  196. this.type = type
  197. console.log(this.type)
  198. this.sa_quotedpriceid = id
  199. this.productData()
  200. },
  201. /*产品配置信息*/
  202. async productData(){
  203. console.log("执行")
  204. console.log(this.sa_quotedpriceid,"报价单id四")
  205. this.params.content.sa_quotedpriceid = this.sa_quotedpriceid
  206. const res = await this.$api.requested(this.params)
  207. this.list = res.data
  208. this.total = res.total
  209. console.log(res,'产品配置信息')
  210. console.log(this.type)
  211. this.$nextTick(()=>{
  212. console.log(this.type)
  213. if (this.type === '项目报价'){
  214. for (let i=0;i<this.list.length;i++){
  215. this.$refs.multipleTable.toggleRowSelection(this.list[i],true)
  216. }
  217. }
  218. })
  219. },
  220. handleSizeChange(val) {
  221. // console.log(`每页 ${val} 条`);
  222. this.param.content.pageSize = val
  223. this.productData()
  224. },
  225. handleCurrentChange(val) {
  226. // console.log(`当前页: ${val}`);
  227. this.param.content.pageNumber = val
  228. this.productData()
  229. },
  230. onSuccess(){
  231. this.productData()
  232. },
  233. clearData(){
  234. console.log("执行")
  235. this.search = ""
  236. this.param.content.where.condition = this.search
  237. this.productData()
  238. },
  239. queryClick(){
  240. this.param.content.where.condition = this.search
  241. this.productData()
  242. },
  243. selectionChange(val){
  244. console.log(val)
  245. this.tableSelectData = val
  246. if (this.type === '项目报价'){
  247. let obj = this.tableSelectData.map(e=>{
  248. return {
  249. sa_quotedprice_itemsid:'0',
  250. itemid:e.itemid,
  251. oldprice:e.marketprice,
  252. /*price:(e.marketprice * 100)/100,*/
  253. price:0,
  254. discountrate:0,
  255. qty:e.qty
  256. }
  257. })
  258. console.log(obj)
  259. this.selectData = obj
  260. }else {
  261. let obj = this.tableSelectData.map(e=>{
  262. return {
  263. sa_quotedprice_itemsid:'0',
  264. itemid:e.itemid,
  265. oldprice:e.marketprice,
  266. /*price:(e.marketprice * 100)/100,*/
  267. price:0,
  268. discountrate:0,
  269. qty:1
  270. }
  271. })
  272. console.log(obj)
  273. this.selectData = obj
  274. }
  275. }
  276. },
  277. mounted() {
  278. }
  279. }
  280. </script>
  281. <style scoped>
  282. .image {
  283. width:40px;height:40px;margin:0px auto;
  284. }
  285. </style>