productTableProject.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. :show-close="false"
  10. direction="rtl"
  11. @close="onColes">
  12. <div class="drawer__panel">
  13. <div class="flex-align-center flex-between ">
  14. <slot name="operation"></slot>
  15. <div class="flex-align-center">
  16. <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;
  17. </div>
  18. <div style="margin-top:-10px;margin-bottom: 10px;float: right">
  19. <el-button style="float: right" type="primary" size="mini" @click="batchSelect" :disabled="tableSelectData.length === 0 ">批量添加</el-button>
  20. </div>
  21. </div>
  22. <div class="produtMag-panel">
  23. <el-table
  24. ref="multipleTable"
  25. :data="list"
  26. style="width: 100%"
  27. :header-cell-style="{height:'50px',color:'#606266',fontWeight:'400'}"
  28. :cell-style="{height:'50px',color:'#666666',fontWeight:'400'}"
  29. @selection-change="selectionChange">
  30. <el-table-column
  31. type="selection"
  32. width="42"
  33. fixed>
  34. </el-table-column>
  35. <el-table-column
  36. align="center"
  37. label="产品图"
  38. width="80">
  39. <template slot-scope="scope">
  40. <div v-if="scope.row.attinfos[0]">
  41. <previewImage class="image" :image="scope.row.attinfos[0]" :list="scope.row.attinfos" :deletebtn="false"></previewImage>
  42. </div>
  43. </template>
  44. </el-table-column>
  45. <el-table-column
  46. prop="itemno"
  47. label="产品编号"
  48. width="180">
  49. </el-table-column>
  50. <el-table-column
  51. prop="itemname"
  52. label="产品名称"
  53. width="180">
  54. </el-table-column>
  55. <el-table-column
  56. label="型号/规格"
  57. width="180">
  58. <template slot-scope="scope">
  59. <p><span>{{scope.row.model}}</span>&nbsp;/&nbsp;<span>{{scope.row.spec}}</span></p>
  60. </template>
  61. </el-table-column>
  62. <el-table-column
  63. prop="caliber"
  64. label="口径"
  65. width="180">
  66. </el-table-column>
  67. <el-table-column
  68. prop="pressure"
  69. label="压力"
  70. width="180">
  71. </el-table-column>
  72. <el-table-column
  73. prop="material"
  74. label="材质"
  75. width="180">
  76. </el-table-column>
  77. <el-table-column
  78. prop="brand"
  79. label="品牌"
  80. width="180">
  81. <template slot-scope="scope">
  82. <p v-for="(item,index) in scope.row.brand">
  83. <span style="float: left" v-if="index === scope.row.brand.length -1">{{item?item.brandname+'':'--'}}</span>
  84. <span style="float: left" v-else>{{item?item.brandname+',':'--'}}</span>
  85. </p>
  86. </template>
  87. </el-table-column>
  88. <el-table-column
  89. prop="itemclass"
  90. label="类别"
  91. width="0">
  92. <template slot-scope="scope">
  93. <p v-for="(item,index) in scope.row.itemclass">
  94. <span style="float: left" v-if="index === scope.row.itemclass.length -1">{{item?item.itemclassname+'':'--'}}</span>
  95. <span style="float: left" v-else>{{item?item.itemclassname+',':'--'}}</span>
  96. </p>
  97. </template>
  98. </el-table-column>
  99. <el-table-column
  100. prop="unitid"
  101. label="计量单位"
  102. width="100">
  103. <template slot-scope="scope">
  104. <el-tag size="mini" type="info" effect="plain">{{scope.row.unitname}}/{{scope.row.axunitname}}</el-tag>
  105. </template>
  106. </el-table-column>
  107. <el-table-column
  108. prop="marketprice"
  109. label="牌价(元)"
  110. fixed="right"
  111. width="100">
  112. <template slot-scope="scope">
  113. <span >{{scope.row.marketprice?scope.row.marketprice:'--'}}</span>
  114. </template>
  115. </el-table-column>
  116. <el-table-column
  117. prop="totalPrice"
  118. fixed="right"
  119. label="操作"
  120. width="80">
  121. <template slot-scope="scope">
  122. <el-button type="text" @click="onSelect(scope.row)">添 加</el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. <div>
  127. <div style="float: left">已选:{{selectTotal}}个商品</div>
  128. <div style="margin-top:16px;text-align:right">
  129. <el-pagination
  130. background
  131. small
  132. @size-change="handleSizeChange"
  133. @current-change="handleCurrentChange"
  134. :current-page="currentPage"
  135. :page-size="params.content.pageSize"
  136. layout="total, prev, pager, next, jumper"
  137. :total="total">
  138. </el-pagination>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. <div class="fixed__btn__panel">
  144. <el-button size="small" @click="onColes" class="normal-btn-width">取 消</el-button>
  145. <!-- <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>-->
  146. </div>
  147. </el-drawer>
  148. </div>
  149. </template>
  150. <script>
  151. import uploadFile from "@/components/upload/hw_obs_upload";
  152. import previewImage from "@/components/previewImage";
  153. export default {
  154. name: "productTable",
  155. props:["id"],
  156. components:{uploadFile, previewImage},
  157. data(){
  158. return {
  159. dialogProductVisible:false,
  160. type:'',
  161. tablecols:[],
  162. list:[],
  163. total:0,
  164. currentPage:0,
  165. tableSelectData:[],
  166. selectData:[],
  167. selectTotal:0,
  168. sa_quotedpriceid:'',
  169. params:{
  170. "id": 20221020164903,
  171. "version":1,
  172. "content": {
  173. "sa_projectid":'',
  174. "sa_quotedpriceid":"",
  175. "pageNumber": 1,
  176. "pageSize": 20,
  177. "where": {
  178. "condition": ""
  179. }
  180. }
  181. },
  182. timer:0
  183. }
  184. },
  185. methods:{
  186. onShow(){
  187. /* this.dialogProjectVisible = true*/
  188. this.$emit('checkFormProject','project')
  189. /*this.productData()*/
  190. },
  191. onColes(){
  192. this.dialogProductVisible = false
  193. },
  194. async onSubmit(){
  195. const res = await this.$api.requested({
  196. "id": 20221021095403,
  197. "content": {
  198. "sa_quotedpriceid":this.sa_quotedpriceid, //sat_notice_classid<=0时 为新增
  199. "items":this.selectData
  200. }
  201. })
  202. this.tool.showMessage(res,()=>{
  203. /*this.dialogProductVisible = false*/
  204. this.$emit('productAdd')
  205. this.queryProduct(this.sa_quotedpriceid,this.type)
  206. this.selectListData()
  207. })
  208. },
  209. batchSelect(){
  210. this.debounce(this.onSubmit,300)()
  211. },
  212. onSelect(val){
  213. console.log(val,"选择的商品")
  214. this.tableSelectData = []
  215. this.tableSelectData[0] = val
  216. let obj = this.tableSelectData.map(e=>{
  217. return {
  218. sa_quotedprice_itemsid:'0',
  219. itemid:e.itemid,
  220. oldprice:e.marketprice,
  221. /*price:(e.marketprice * 100)/100,*/
  222. price:0,
  223. discountrate:0,
  224. qty:1
  225. }
  226. })
  227. this.selectData = obj
  228. /*this.$nextTick(()=>{
  229. this.onSubmit()
  230. })*/
  231. this.debounce(this.onSubmit,300)()
  232. },
  233. debounce (fn, wait) {
  234. let that = this
  235. return function () {
  236. if (that.timer !== null) clearTimeout(that.timer)
  237. that.timer = setTimeout(fn, wait)
  238. }
  239. },
  240. /*获取产品信息*/
  241. queryProduct(id,type){
  242. this.dialogProductVisible = true
  243. this.params.content.sa_projectid = this.id
  244. this.type = type
  245. this.sa_quotedpriceid = id
  246. this.productData()
  247. },
  248. /*产品配置信息*/
  249. async productData(){
  250. this.params.content.sa_quotedpriceid = this.sa_quotedpriceid
  251. const res = await this.$api.requested(this.params)
  252. this.list = res.data
  253. this.total = res.total
  254. this.$nextTick(()=>{
  255. if (this.type === '项目报价'){
  256. for (let i=0;i<this.list.length;i++){
  257. this.$refs.multipleTable.toggleRowSelection(this.list[i],true)
  258. }
  259. }
  260. })
  261. },
  262. handleSizeChange(val) {
  263. // console.log(`每页 ${val} 条`);
  264. this.param.content.pageSize = val
  265. this.productData()
  266. },
  267. handleCurrentChange(val) {
  268. // console.log(`当前页: ${val}`);
  269. this.param.content.pageNumber = val
  270. this.productData()
  271. },
  272. onSuccess(){
  273. this.productData()
  274. },
  275. clearData(){
  276. this.search = ""
  277. this.param.content.where.condition = this.search
  278. this.productData()
  279. },
  280. queryClick(){
  281. this.param.content.where.condition = this.search
  282. this.productData()
  283. },
  284. selectionChange(val){
  285. this.tableSelectData = []
  286. this.tableSelectData = val
  287. if (this.type === '项目报价'){
  288. let obj = this.tableSelectData.map(e=>{
  289. return {
  290. sa_quotedprice_itemsid:'0',
  291. itemid:e.itemid,
  292. oldprice:e.marketprice,
  293. /*price:(e.marketprice * 100)/100,*/
  294. price:0,
  295. discountrate:0,
  296. qty:e.qty
  297. }
  298. })
  299. this.selectData = obj
  300. }else {
  301. let obj = this.tableSelectData.map(e=>{
  302. return {
  303. sa_quotedprice_itemsid:'0',
  304. itemid:e.itemid,
  305. oldprice:e.marketprice,
  306. /*price:(e.marketprice * 100)/100,*/
  307. price:0,
  308. discountrate:0,
  309. qty:1
  310. }
  311. })
  312. this.selectData = obj
  313. }
  314. },
  315. /*已选产品数据*/
  316. async selectListData(){
  317. const res = await this.$api.requested({
  318. "id": 20221021095503,
  319. "content": {
  320. "sa_quotedpriceid":this.sa_quotedpriceid //sat_notice_classid<=0时 为新增
  321. }
  322. })
  323. console.log(res,"已选产品123456")
  324. this.selectTotal = res.total
  325. console.log(res.total,"已选产品数量")
  326. }
  327. },
  328. mounted() {
  329. }
  330. }
  331. </script>
  332. <style scoped>
  333. .image {
  334. width:38px;height:38px;margin:0px auto;
  335. }
  336. </style>