productTableProject.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <div>
  3. <el-button size="small" type="primary" icon="el-icon-plus" @click="queryProduct">自项目产品添加</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","sa_quotedpriceid","quotedpricetype"],
  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. "content": {
  178. "sa_quotedpriceid":this.sa_quotedpriceid, //sat_notice_classid<=0时 为新增
  179. "items":this.selectData
  180. }
  181. })
  182. this.tool.showMessage(res,()=>{
  183. console.log(res)
  184. this.dialogProductVisible = false
  185. this.$emit('productAdd')
  186. })
  187. },
  188. /*获取产品信息*/
  189. queryProduct(){
  190. this.dialogProductVisible = true
  191. console.log(this.id,this.sa_quotedpriceid,"接受传过来的数据")
  192. this.params.content.sa_projectid = this.id
  193. this.productData()
  194. },
  195. /*产品配置信息*/
  196. async productData(){
  197. console.log("执行")
  198. this.params.content.sa_quotedpriceid = this.sa_quotedpriceid
  199. const res = await this.$api.requested(this.params)
  200. console.log(res,"产品配置")
  201. this.list = res.data
  202. this.total = res.total
  203. console.log(res,'产品配置信息')
  204. console.log(this.quotedpricetype)
  205. this.$nextTick(()=>{
  206. console.log(this.quotedpricetype)
  207. if (this.quotedpricetype === '项目报价'){
  208. for (let i=0;i<this.list.length;i++){
  209. this.$refs.multipleTable.toggleRowSelection(this.list[i],true)
  210. }
  211. }
  212. })
  213. },
  214. handleSizeChange(val) {
  215. // console.log(`每页 ${val} 条`);
  216. this.param.content.pageSize = val
  217. this.productData()
  218. },
  219. handleCurrentChange(val) {
  220. // console.log(`当前页: ${val}`);
  221. this.param.content.pageNumber = val
  222. this.productData()
  223. },
  224. onSuccess(){
  225. this.productData()
  226. },
  227. clearData(){
  228. console.log("执行")
  229. this.search = ""
  230. this.param.content.where.condition = this.search
  231. this.productData()
  232. },
  233. queryClick(){
  234. this.param.content.where.condition = this.search
  235. this.productData()
  236. },
  237. selectionChange(val){
  238. console.log(val)
  239. this.tableSelectData = val
  240. if (this.type === '项目报价'){
  241. let obj = this.tableSelectData.map(e=>{
  242. return {
  243. sa_quotedprice_itemsid:'0',
  244. itemid:e.itemid,
  245. oldprice:e.marketprice,
  246. /*price:(e.marketprice * 100)/100,*/
  247. price:0,
  248. discountrate:0,
  249. qty:e.qty
  250. }
  251. })
  252. console.log(obj)
  253. this.selectData = obj
  254. }else {
  255. let obj = this.tableSelectData.map(e=>{
  256. return {
  257. sa_quotedprice_itemsid:'0',
  258. itemid:e.itemid,
  259. oldprice:e.marketprice,
  260. /*price:(e.marketprice * 100)/100,*/
  261. price:0,
  262. discountrate:0,
  263. qty:1
  264. }
  265. })
  266. console.log(obj)
  267. this.selectData = obj
  268. }
  269. }
  270. },
  271. mounted() {
  272. }
  273. }
  274. </script>
  275. <style scoped>
  276. .image {
  277. width:38px;height:38px;margin:0px auto;
  278. }
  279. </style>