productTable.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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>&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.dialogProductVisible = true
  197. setTimeout(()=>{
  198. this.params.content.where.tradefield = this.$refs.classShow.field_act
  199. this.params.content.where.standards = this.$refs.classShow.standard_act
  200. /* this.params.content.where.itemclassid = this.$refs.classShow.class_act*/
  201. this.params.content.where.sa_brandid = this.$refs.classShow.brand_act
  202. this.productData()
  203. this.selectListData()
  204. },1000)
  205. /*this.productData()*/
  206. },
  207. onColes(){
  208. this.dialogProductVisible = false
  209. },
  210. async onSubmit(){
  211. const res = await this.$api.requested({
  212. "id": 20221021095403,
  213. "content": {
  214. "sa_quotedpriceid":this.$route.query.id, //sat_notice_classid<=0时 为新增
  215. "items":this.selectData
  216. }
  217. })
  218. this.tool.showMessage(res,()=>{
  219. /*this.dialogProductVisible = false*/
  220. this.$emit('productAdd')
  221. this.productData()
  222. this.selectListData()
  223. })
  224. },
  225. onSelect(val){
  226. console.log(val,"选择的商品")
  227. this.tableSelectData = []
  228. this.tableSelectData[0] = val
  229. let obj = this.tableSelectData.map(e=>{
  230. return {
  231. sa_quotedprice_itemsid:'0',
  232. itemid:e.itemid,
  233. oldprice:e.marketprice,
  234. /*price:(e.marketprice * 100)/100,*/
  235. price:e.marketprice,
  236. discountrate:1,
  237. qty:1
  238. }
  239. })
  240. this.selectData = obj
  241. /*this.$nextTick(()=>{
  242. this.onSubmit()
  243. })*/
  244. this.debounce(this.onSubmit,300)()
  245. },
  246. batchSelect(){
  247. this.debounce(this.onSubmit,300)()
  248. },
  249. debounce (fn, wait) {
  250. let that = this
  251. return function () {
  252. if (that.timer !== null) clearTimeout(that.timer)
  253. that.timer = setTimeout(fn, wait)
  254. }
  255. },
  256. /*获取产品信息*/
  257. queryProduct(id,type){
  258. this.dialogProductVisible = true
  259. this.params.content.sa_projectid = 0
  260. this.type = type
  261. this.sa_quotedpriceid = id
  262. this.productData()
  263. },
  264. /*产品配置信息*/
  265. async productData(){
  266. this.params.content.sa_quotedpriceid = this.$route.query.id
  267. this.params.content.sa_projectid = 0
  268. const res = await this.$api.requested(this.params)
  269. this.list = res.data
  270. this.total = res.total
  271. /*this.$nextTick(()=>{
  272. if (this.type === '项目报价'){
  273. for (let i=0;i<this.list.length;i++){
  274. this.$refs.multipleTable.toggleRowSelection(this.list[i],true)
  275. }
  276. }
  277. })*/
  278. },
  279. handleSizeChange(val) {
  280. // console.log(`每页 ${val} 条`);
  281. this.param.content.pageSize = val
  282. this.productData()
  283. },
  284. handleCurrentChange(val) {
  285. // console.log(`当前页: ${val}`);
  286. this.param.content.pageNumber = val
  287. this.productData()
  288. },
  289. onSuccess(){
  290. this.productData()
  291. },
  292. clearData(){
  293. this.search = ""
  294. this.param.content.where.condition = this.search
  295. this.productData()
  296. },
  297. queryClick(){
  298. this.param.content.where.condition = this.search
  299. this.productData()
  300. },
  301. selectionChange(val){
  302. this.tableSelectData = []
  303. this.tableSelectData = val
  304. if (this.type === '项目报价'){
  305. let obj = this.tableSelectData.map(e=>{
  306. return {
  307. sa_quotedprice_itemsid:'0',
  308. itemid:e.itemid,
  309. oldprice:e.marketprice,
  310. /*price:(e.marketprice * 100)/100,*/
  311. price:e.marketprice,
  312. discountrate:1,
  313. qty:1
  314. }
  315. })
  316. this.selectData = obj
  317. }else {
  318. let obj = this.tableSelectData.map(e=>{
  319. return {
  320. sa_quotedprice_itemsid:'0',
  321. itemid:e.itemid,
  322. oldprice:e.marketprice,
  323. /*price:(e.marketprice * 100)/100,*/
  324. price:e.marketprice,
  325. discountrate:1,
  326. qty:1
  327. }
  328. })
  329. this.selectData = obj
  330. }
  331. },
  332. /*已选产品数据*/
  333. async selectListData(){
  334. const res = await this.$api.requested({
  335. "id": 20221021095503,
  336. "content": {
  337. "sa_quotedpriceid":this.$route.query.id //sat_notice_classid<=0时 为新增
  338. }
  339. })
  340. console.log(res,"已选产品123456")
  341. this.selectTotal = res.total
  342. console.log(res.total,"已选产品数量")
  343. },
  344. brandChange(id) {
  345. this.brandId = id
  346. this.productData()
  347. },
  348. onClassChange (n) {
  349. this.params.content.where.itemclassid = n.itemclassid
  350. this.productData()
  351. },
  352. Search(data) {
  353. this.params.content.where.condition = data
  354. this.params.content.pageNumber = 1
  355. this.productData()
  356. },
  357. clearSearch() {
  358. this.params.content.where.condition = ''
  359. this.params.content.pageNumber = 1
  360. this.productData()
  361. },
  362. clickField (item) {
  363. console.log(item,'clickField')
  364. this.params.content.where.tradefield = item.value
  365. this.productData()
  366. },
  367. clickStandard (item){
  368. this.params.content.where.standards = item.value
  369. this.productData()
  370. }
  371. },
  372. mounted() {
  373. }
  374. }
  375. </script>
  376. <style scoped>
  377. .image {
  378. width:38px;height:38px;margin:0px auto;
  379. }
  380. </style>