productTableProject.vue 13 KB

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