<!DOCTYPE html> <html> <head> <title>作业配置项-列表</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <!-- 所有的 css & js 资源 --> <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css"> <link rel="stylesheet" href="../../static/sa.css"> <script src="../../static/kj/vue.min.js"></script> <script src="../../static/kj/element-ui/index.js"></script> <script src="../../static/kj/httpVueLoader.js"></script> <script src="../../static/kj/jquery.min.js"></script> <script src="../../static/kj/layer/layer.js"></script> <script src="../../static/sa.js"></script> </head> <body> <div class="vue-box" style="display: none;" :style="'display: block;'"> <div class="c-panel"> <!-- ------------- 检索参数 ------------- --> <div class="c-title">检索参数</div> <el-form ref="form" :model='p' @submit.native.prevent> <sa-item type="text" name="项目名称" v-model="p.name"></sa-item> <el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button> <sa-item type="fast-btn" show="reset" style="display: inline;"></sa-item> <el-button type="primary" icon="el-icon-plus" @click="selectBatch()">确定 </el-button> <br /> </el-form> <!-- ------------- 数据列表 ------------- --> <el-table class="data-table" ref="data-table" :data="dataList"> <sa-td type="selection"></sa-td> <sa-td name="收费项名称" prop="name"></sa-td> <!-- <sa-td name="付款步骤" prop="payStep" type="enum" :jv="{1: '下单后', 2: '确认后'}"></sa-td> --> <sa-td name="排序" prop="sort"></sa-td> <el-table-column label="操作" fixed="right"> <template slot-scope="s"> <el-button class="c-btn" type="primary" icon="el-icon-edit" @click="selectOne(s.row)">选择 </el-button> </template> </el-table-column> </el-table> <el-pagination :page-size="p.pageSize" :current-page="p.pageNo" layout="prev, pager, next" :total="dataCount" @current-change="pageChange"> </el-pagination> </div> </div> <script> var app = new Vue({ components: { "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'), "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'), }, el: '.vue-box', data: { ids: sa.p('idStr', ''), goodsId: sa.p('goodsId', ''), p: { // 查询参数 id: '', // 主键 name: '', // 项目名称 pageNo: 1, // 当前页 pageSize: 15, // 页大小 sortType: 0 // 排序方式 }, dataCount: 0, dataList: [], // 数据集合 selection:[] }, methods: { // 新增 selectBatch: function(data) { var selection = this.$refs['data-table'].selection; if (selection.length == 0) { return sa.msg('至少选择一条数据') } selection=selection.concat(this.selection); let obj = { goodsId: this.goodsId, typeIds: selection.map(obj => obj.id).join(',') } sa.ajax('/RelationGoodsType/saveBatch', obj, function(res) { sa.alert('添加成功'); setTimeout(() => { sa.closeCurrIframe(); // 关闭本页 parent.app.f5(); // 刷新父页面列表 }, 1000) }.bind(this)); }, // 删除 selectOne: function(data) { let obj = { goodsId: this.goodsId, typeId: data.id } sa.ajax('/RelationGoodsType/saveSingle', obj, function(res) { sa.alert('添加成功'); this.ids = this.ids + ',' + data.id; this.f5(); }.bind(this)); }, pageChange(p) { this.selection=this.selection.concat(this.$refs['data-table'].selection); this.p.pageNo = p; this.f5(); }, // 刷新 f5: function() { sa.ajax('/TbItemType/getList', sa.removeNull(this.p), function(res) { let list = res.data; this.dataList = list; // 数据 this.dataCount = res.dataCount; // 数据总数 let ids = this.ids.split(','); ids=ids.concat(this.selection); list.forEach(row => { if (ids.indexOf(row.id) !== -1) { this.$nextTick(() => { this.$refs['data-table'].toggleRowSelection(row, true) }) } }) sa.f5TableHeight(); // 刷新表格高度 }.bind(this)); }, }, created: function() { this.f5(); sa.onInputEnter(); } }) </script> </body> </html>