123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>业务顺序-添加/修改</title>
- <meta http-equiv="Content-Type" content="text/html; 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>
- <style type="text/css">
- .c-panel .el-form .c-label {
- width: 7em !important;
- }
- .c-panel .el-form .el-input,
- .c-panel .el-form .el-textarea__inner {
- width: 250px;
- }
- .item-num .el-input__inner {
- width: 130px;
- display: inline;
- }
- </style>
- </head>
- <body>
- <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
- <!-- ------- 内容部分 ------- -->
- <div class="s-body">
- <div class="c-panel">
- <div class="c-title" v-if="id == 0">数据添加</div>
- <div class="c-title" v-else>数据修改</div>
- <el-form v-if="m">
- <div v-for="item in list" :key="item.index">
- <div class="c-item" v-if="item.index>0">
- <label class="c-label">间隔(分):</label>
- <el-input-number class="item-num" v-model="item.interval" :step="10" :min="0"
- :max="9999">
- </el-input-number>
- </div>
- <div class="c-item">
- <label class="c-label">第{{item.index + 1}}个:</label>
- <el-select v-model="item.typeId" placeholder="请选择">
- <el-option :label="type.name" :value="type.id"
- v-for="(type,index) in item.businessTypeList">
- </el-option>
- </el-select>
- <el-button @click="handlerAdd" v-if="item.index==0">添加项</el-button>
- <el-button @click="handlerDel(item.index)" v-if="item.index>0">删除项</el-button>
- </div>
- </div>
- <sa-item name="" class="s-ok" br>
- <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
- </sa-item>
- </el-form>
- </div>
- </div>
- <!-- ------- 底部按钮 ------- -->
- <div class="s-foot">
- <el-button type="primary" @click="ok()">确定</el-button>
- <el-button @click="sa.closeCurrIframe()">取消</el-button>
- </div>
- </div>
- <script>
- var app = new Vue({
- components: {
- "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
- },
- el: '.vue-box',
- data: {
- id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
- m: null, // 实体对象
- list: [],
- businessTypeList: [],
- },
- methods: {
- handlerAdd() {
- let list = this.list;
- let businessTypeList = this.businessTypeList;
- this.list.push({
- index: list.length,
- typeId: businessTypeList[0].id,
- interval: 30,
- businessTypeList: businessTypeList
- })
- },
- handlerDel(index) {
- let list = this.list;
- list.splice(index, 1);
- for (let i in list) {
- let obj = list[i];
- if (obj.index > index) {
- obj.index = obj.index - 1;
- }
- }
- this.list = list;
- },
- getBusinessType() {
- this.list = [];
- sa.ajax('/TbItemType/getList', function (resp) {
- let list = resp.data;
- this.businessTypeList = list;
- this.getSortList();
- }.bind(this))
- },
- getSortList() {
- console.log(111)
- sa.ajax('/TbBusinessOrder/getList', function (resp) {
- let dbList = resp.data;
- let businessTypeList = this.businessTypeList;
- let index = 0;
- let list = [];
- for (let i in dbList) {
- let item = dbList[i];
- let obj = {
- id: item.id,
- index: index,
- typeId: item.typeId,
- interval: item.intervalTime,
- businessTypeList: businessTypeList
- }
- list.push(obj);
- index++;
- }
- this.list = list;
- }.bind(this))
- },
- // 创建一个 默认Model
- createModel: function () {
- return {
- id: '', //
- name: '', //
- typeId: '',
- typeName: '', //
- sort: '', //
- }
- },
- // 提交数据
- ok: function () {
- // 表单校验
- let m = this.m;
- sa.checkNull(m.id, '请输入 []');
- sa.checkNull(m.name, '请输入 []');
- sa.checkNull(m.typeName, '请输入 []');
- sa.checkNull(m.sort, '请输入 []');
- // 开始增加或修改
- if (this.id <= 0) { // 添加
- sa.ajax('/TbBusinessOrder/add', m, function (res) {
- sa.alert('增加成功', this.clean);
- }.bind(this));
- } else { // 修改
- sa.ajax('/TbBusinessOrder/update', m, function (res) {
- sa.alert('修改成功', this.clean);
- }.bind(this));
- }
- },
- // 添加/修改 完成后的动作
- clean: function () {
- if (this.id == 0) {
- this.m = this.createModel();
- } else {
- parent.app.f5(); // 刷新父页面列表
- sa.closeCurrIframe(); // 关闭本页
- }
- }
- },
- mounted: function () {
- this.getBusinessType();
- // 初始化数据
- }
- })
- </script>
- </body>
- </html>
|