productTableProject.vue 14 KB

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