productTable.vue 14 KB

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