productTableCopy.vue 12 KB

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