add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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 style="display:flex;align-items:center;margin-bottom:10px">
  14. <span class="header-title">选择报价单:</span>
  15. <el-popover
  16. placement="bottom"
  17. width="700"
  18. trigger="click"
  19. v-model="priceShow"
  20. @show="priceList">
  21. <el-input
  22. style="width:300px;margin-bottom: 10px"
  23. placeholder="请输入内容"
  24. v-model="params2.content.where.condition"
  25. clearable
  26. @clear="priceList(params2.content.pageNumber = 1)"
  27. size="mini"
  28. @keyup.enter.native="priceList(params2.content.pageNumber = 1)">
  29. <i slot="prefix" class="el-icon-search" @click="priceList(params2.content.pageNumber = 1)"></i>
  30. </el-input>
  31. <el-table :data="priceData" @row-click="priceDataSelect" height="396px" size="mini">
  32. <el-table-column
  33. label="状态"
  34. width="180">
  35. <template slot-scope="scope">
  36. <span style="margin-left: 10px">{{ scope.row.status?scope.row.status:'--' }}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column
  40. label="单号"
  41. width="200">
  42. <template slot-scope="scope">
  43. <span style="margin-left: 10px">{{ scope.row.billno?scope.row.billno:'--'}}</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column
  47. label="提交人"
  48. >
  49. <template slot-scope="scope">
  50. <span style="margin-left: 10px">{{ scope.row.submitby?scope.row.submitby:'--' }}</span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column
  54. label="提交时间"
  55. >
  56. <template slot-scope="scope">
  57. <span style="margin-left: 10px">{{ scope.row.submitdate?scope.row.submitdate:'--' }}</span>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. <div class="container normal-panel" style="text-align:right">
  62. <el-pagination
  63. background
  64. small
  65. @size-change="handleSizeChangePrice"
  66. @current-change="handleCurrentChangePrice"
  67. :page-sizes="[10,20,50,100]"
  68. layout="total,sizes, prev, pager, next, jumper"
  69. :current-page="currentPage2"
  70. :total="total2">
  71. </el-pagination>
  72. </div>
  73. <el-input slot="reference" :readonly="true" v-model="billno" autocomplete="off" placeholder="请选择报价单" size="small" ></el-input>
  74. </el-popover>
  75. <!-- <el-input readonly type="text" placeholder="选择报价单" style="width:200px" size="small" v-model="billno" ></el-input>-->
  76. </div>
  77. <el-divider></el-divider>
  78. <div class="flex-between " style="margin-bottom: 10px">
  79. <uploadAllData
  80. style="display: inline-block !important;"
  81. :total="total"
  82. @handlePullApi="handlePullApi"
  83. @handleUploadApi="handleUploadApi"
  84. @onSuccess="onSuccess"
  85. ></uploadAllData>
  86. <el-button class="inline-16" type="primary" size="small" @click="itemClassSelect" :disabled="tableSelectData.length === 0 ">批量添加</el-button>
  87. <el-input size="small" style="width: 200px" suffix-icon="el-icon-search" v-model="params.content.where.condition" placeholder="编号、类别名称、品牌" @keyup.enter.native="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" clearable></el-input>&nbsp;
  88. </div>
  89. <div class="produtMag-panel">
  90. <el-table
  91. ref="multipleTable"
  92. :data="list"
  93. style="width: 100%"
  94. height="calc(100vh - 370px)"
  95. :header-cell-style="{height:'50px',color:'#606266',fontWeight:'400'}"
  96. :cell-style="{height:'50px',color:'#666666',fontWeight:'400'}"
  97. @selection-change="selectionChange">
  98. <el-table-column
  99. type="selection"
  100. width="42"
  101. fixed>
  102. </el-table-column>
  103. <el-table-column
  104. prop="itemclassnum"
  105. label="类别编号"
  106. width="0">
  107. </el-table-column>
  108. <el-table-column
  109. prop="itemclassfullname"
  110. label="类别名称"
  111. width="0">
  112. </el-table-column>
  113. <el-table-column
  114. prop="brandname"
  115. label="品牌"
  116. width="0">
  117. </el-table-column>
  118. <!-- <el-table-column
  119. label="品牌名称"
  120. width="180">
  121. <template slot-scope="scope">
  122. <p><span>{{scope.row.model}}</span>&nbsp;/&nbsp;<span>{{scope.row.spec}}</span></p>
  123. </template>
  124. </el-table-column>-->
  125. <!-- <el-table-column
  126. prop="upitemclassname"
  127. label="上级类别"
  128. width="0">
  129. </el-table-column>-->
  130. <el-table-column
  131. prop="discountrate"
  132. label="折扣(%)"
  133. width="0">
  134. <template slot-scope="scope">
  135. <span>{{Math.round((scope.row.discountrate * 100)*100)/100}}</span>
  136. </template>
  137. </el-table-column>
  138. <el-table-column
  139. fixed="right"
  140. label="操作"
  141. width="80">
  142. <template slot-scope="scope">
  143. <el-button type="text" @click="itemClass(scope.row)">添 加</el-button>
  144. </template>
  145. </el-table-column>
  146. </el-table>
  147. <div>
  148. <div style="float: left">已选:{{selectTotal}}个商品</div>
  149. <div style="margin-top:16px;text-align:right">
  150. <el-pagination
  151. background
  152. @size-change="handleSizeChange"
  153. @current-change="handleCurrentChange"
  154. :current-page="params.content.pageNumber"
  155. :page-sizes="[20, 50, 100, 200]"
  156. :page-size="100"
  157. layout="total,sizes, prev, pager, next, jumper"
  158. :total="total">
  159. </el-pagination>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. <div class="fixed__btn__panel">
  165. <el-button size="small" @click="onColes" class="normal-btn-width">取 消</el-button>
  166. <!-- <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>-->
  167. </div>
  168. </el-drawer>
  169. </div>
  170. </template>
  171. <script>
  172. import uploadAllData from '@/components/uploadAllData/index'
  173. export default {
  174. name: "add",
  175. components:{uploadAllData},
  176. props:["data"],
  177. data(){
  178. return {
  179. dialogProductVisible:false,
  180. tablecols:[],
  181. list:[],
  182. total:0,
  183. currentPage:0,
  184. total2:0,
  185. currentPage2:0,
  186. tableSelectData:[],
  187. selectData:[],
  188. selectTotal:0,
  189. priceShow:false,
  190. priceData:[],
  191. billno:'',
  192. params:{
  193. "id": 20230219202203,
  194. "content": {
  195. "sa_contractid": this.$route.query.id,
  196. "sa_quotedpriceid":'',
  197. "pageNumber": 1,
  198. "pageSize": 100,
  199. "where": {
  200. "condition": ""
  201. }
  202. },
  203. },
  204. params2: {
  205. "id": 20221222151302,
  206. "content": {
  207. "sa_projectid": '',
  208. "pageNumber": 1,
  209. "pageSize": 20,
  210. "nocache":true,
  211. "where": {
  212. "condition": ""
  213. }
  214. },
  215. },
  216. timer:0
  217. }
  218. },
  219. methods:{
  220. onShow(){
  221. this.dialogProductVisible = true
  222. /* this.listData()*/
  223. /*this.priceList()*/
  224. },
  225. async listData(){
  226. const res = await this.$api.requested(this.params)
  227. this.list = res.data
  228. this.total = res.total
  229. },
  230. debounce (fn, wait) {
  231. let that = this
  232. return function () {
  233. if (that.timer !== null) clearTimeout(that.timer)
  234. that.timer = setTimeout(fn, wait)
  235. }
  236. },
  237. async itemClassSelect(){
  238. let checkItem = []
  239. this.selectData.forEach((item,index)=>{
  240. checkItem[index] = item.itemclassid
  241. })
  242. const res = await this.$api.requested({
  243. "id": 20230223201103,
  244. "content": {
  245. "sa_contractid": this.$route.query.id,
  246. "itemclassids":checkItem
  247. },
  248. })
  249. if (!res.data){
  250. this.batchSelect()
  251. }else {
  252. this.checkItems()
  253. }
  254. },
  255. batchSelect(){
  256. this.debounce(this.onSubmit,300)()
  257. },
  258. async onSubmit(){
  259. const res = await this.$api.requested({
  260. "id": 20221124110202,
  261. "content": {
  262. "sa_contractid":this.$route.query.id, //sat_notice_classid<=0时 为新增
  263. "items":this.selectData
  264. }
  265. })
  266. this.tool.showMessage(res,()=>{
  267. this.$emit('itemClassAdd')
  268. this.listData()
  269. this.selectListData()
  270. })
  271. },
  272. async itemClass(data){
  273. const res = await this.$api.requested({
  274. "id": 20230223201103,
  275. "content": {
  276. "sa_contractid": this.$route.query.id,
  277. "itemclassids":[data.itemclassid]
  278. },
  279. })
  280. if (!res.data){
  281. this.onSelect(data)
  282. }else {
  283. this.checkItem(data)
  284. }
  285. },
  286. onSelect(val){
  287. this.tableSelectData = []
  288. this.tableSelectData[0] = val
  289. let obj = this.tableSelectData.map(e=>{
  290. return {
  291. "sa_contract_itemsaleclassid":0,
  292. "itemclassid":e.itemclassid,
  293. "discountrate":e.discountrate
  294. }
  295. })
  296. this.selectData = obj
  297. /*this.$nextTick(()=>{
  298. this.onSubmit()
  299. })*/
  300. this.debounce(this.onSubmit,300)()
  301. },
  302. handleSizeChange(val) {
  303. // console.log(`每页 ${val} 条`);
  304. this.param.content.pageSize = val
  305. this.productData()
  306. },
  307. handleCurrentChange(val) {
  308. // console.log(`当前页: ${val}`);
  309. this.param.content.pageNumber = val
  310. this.productData()
  311. },
  312. selectionChange(val){
  313. this.tableSelectData = []
  314. this.tableSelectData = val
  315. let obj = this.tableSelectData.map(e=>{
  316. return {
  317. "sa_contract_itemsaleclassid":0,
  318. "itemclassid":e.itemclassid,
  319. "discountrate":e.discountrate
  320. }
  321. })
  322. this.selectData = obj
  323. },
  324. onColes(){
  325. this.params2.content.where.condition = ''
  326. this.params.content.where.condition = ''
  327. this.$emit('closeDrawer')
  328. },
  329. /*已选产品数据*/
  330. async selectListData(){
  331. const res = await this.$api.requested({
  332. "id": 20221124135602,
  333. "content": {
  334. "sa_contractid":this.$route.query.id //sat_notice_classid<=0时 为新增
  335. }
  336. })
  337. this.selectTotal = res.total
  338. },
  339. async priceList(){
  340. this.params2.content.sa_projectid = this.data.sa_projectid
  341. const res = await this.$api.requested(this.params2)
  342. this.priceData = res.data
  343. this.total2 = res.total
  344. },
  345. handleSizeChangePrice(val) {
  346. // console.log(`每页 ${val} 条`);
  347. this.params2.content.pageSize = val
  348. },
  349. handleCurrentChangePrice(val) {
  350. // console.log(`当前页: ${val}`);
  351. this.params2.content.pageNumber = val
  352. },
  353. priceDataSelect(row){
  354. this.billno = row.billno
  355. this.priceShow = false
  356. this.params.content.sa_quotedpriceid = row.sa_quotedpriceid
  357. this.listData()
  358. this.selectListData()
  359. },
  360. checkItems() {
  361. this.$confirm('类别已存在, 是否更新最新折扣?', '提示', {
  362. confirmButtonText: '确定',
  363. cancelButtonText: '取消',
  364. closeOnClickModal:false,
  365. type: 'warning'
  366. }).then(() => {
  367. this.batchSelect()
  368. }).catch(() => {
  369. this.$message({
  370. type: 'info',
  371. message: '已取消添加'
  372. });
  373. });
  374. },
  375. checkItem(data) {
  376. this.$confirm('类别已存在, 是否更新最新折扣?', '提示', {
  377. confirmButtonText: '确定',
  378. cancelButtonText: '取消',
  379. closeOnClickModal:false,
  380. type: 'warning'
  381. }).then(() => {
  382. this.onSelect(data)
  383. }).catch(() => {
  384. this.$message({
  385. type: 'info',
  386. message: '已取消添加'
  387. });
  388. });
  389. },
  390. /*拉取数据*/
  391. handlePullApi (pullApi) {
  392. pullApi.content = JSON.parse(JSON.stringify(this.params.content))
  393. pullApi.id = this.params.id
  394. /*pullApi.content.sa_projectid = this.$route.query.id*/
  395. },
  396. /*上传数据*/
  397. handleUploadApi (uploadApi,data) {
  398. uploadApi.id = 20221124110202
  399. uploadApi.content = {
  400. "sa_contractid": this.$route.query.id, //订单ID
  401. "items": data.map(e=>{
  402. return {
  403. "sa_contract_itemsaleclassid":0,
  404. "itemclassid":e.itemclassid,
  405. "discountrate":e.discountrate
  406. }
  407. })
  408. }
  409. this.listData()
  410. },
  411. onSuccess () {
  412. this.listData()
  413. },
  414. },
  415. mounted() {
  416. }
  417. }
  418. </script>
  419. <style scoped>
  420. </style>