| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <html>
- <head>
- <style>
- .tipsIcon {
- font-size: 20px;
- color: #aaa;
- cursor: pointer;
- position: absolute;
- right: -29px;
- top: 10px;
- }
- </style>
- </head>
- <body>
- <div id="space-content">
- <div class="space-form-infor">
- <el-form action="" method="post" :model="obj" ref="obj" label-width="102px">
- <el-form-item :label="item.desc" v-for="(item, index) in conditionData">
- <!-- 共四种表单类型项,input、number、spaceSelect、select -->
- <el-input v-if="item.ui == 'input'" clearable v-model="obj[item.name]"></el-input>
- <el-input v-else-if="item.ui == 'number'" clearable type="number" v-model="obj[item.name]"
- placeholder="请输入数字"></el-input>
- <el-cascader v-else-if="item.ui == 'select'" v-model="obj[item.name]"
- :options="options[item.name + '_options']" :props="props" clearable style="width: 100%;">
- </el-cascader>
- <space-select v-else-if="item.ui == 'spaceSelect' && space.utils.isNull(item.dataService)"
- v-model="obj[item.name]" :predefine="item.name.replace('predefine_','')" datasize="*">
- </space-select>
- <div class="space-select"
- v-else-if="item.ui == 'spaceSelect' && space.utils.notNull(item.dataService)">
- <el-select class="choose-obj" v-model="obj[item.name]" multiple placeholder="请选择" clearable
- :popper-append-to-body="false" style="width: calc(100% - 60px);"
- :disabled="!obj[item.name].length>0" @remove-tag="removeSelectTag(item)"
- @clear="removeSelectTag(item)">
- <el-option v-for="optionItem in chooseDatas[item.name]" :key="optionItem.id"
- :label="optionItem.name" :value="optionItem.id">
- </el-option>
- </el-select>
- <el-button type="button" size="medium" class="choose-btn" icon="el-icon-search"
- @click="chooseClick(item)"></el-button>
- <div v-for="optionItem in obj[item.name]">{{optionItem.name}}</div>
- </div>
- <!-- 提示语 -->
- <el-tooltip v-if="item.tips" effect="dark" :content="item.tips" placement="left">
- <i class="el-icon-warning-outline tipsIcon"></i>
- </el-tooltip>
- </el-form-item>
- </el-form>
- </div>
- <div class="space-form-btn">
- <el-button type="primary" icon="el-icon-circle-check" :loading="loading" @click="submit">保存</el-button>
- <el-button icon="el-icon-circle-close" onclick="space.allFunction.closeDialog();">关闭</el-button>
- </div>
- </div>
- </body>
- <script type="text/javascript">
- var conditionList = '${conditionList}';
- var valList = '${valList}';
- space.vue = new Vue({
- el: space.appContent,
- data: function () {
- return {
- conditionData: space.utils.isNull(conditionList) ? [] : JSON.parse(conditionList),
- obj: {},
- options: {}, //select下拉
- props: { multiple: true }, //select多选
- chooseDatas: {}, //spaceSelect 选中的options
- loading: false,
- valueList: space.utils.isNull(valList) ? [] : JSON.parse(valList), //回显数据
- }
- },
- created: function () {
- var that = this;
- that.conditionData.forEach(function (item) {
- Vue.set(that.obj, item.name, "");
- if (item.ui == "select" && space.utils.notNull(item.dataService)) {
- space.utils.ajax({
- url: "/apps?ark=" + item.dataService,
- dataType: 'json',
- callback: function (data) {
- if (data.code != "success") {
- space.message.warning("接口错误");
- return;
- }
-
- Vue.set(that.options, item.name + "_options", data.data);
- }
- })
- }
- });
- // 数据回显
- that.valueList.forEach(function (item, index) {
- that.obj[item.name] = item.val;
- if (item.data) {
- item.data = JSON.parse(item.data.replace(/"/g, "\""));
- // 判断ui表单类型项
- if (item.ui == "select") { //select选择器
- Vue.set(that.obj, item.name, item.data);
- } else if (item.ui == "spaceSelect") { //对象选择器
- var valAry = item.val.split(',').map(Number); //将数字字符串转为 数字数组
- Vue.set(that.obj, item.name, valAry);
- if(item.name.indexOf("predefine_") < 0) { //非预定义 对象选择器
- Vue.set(that.chooseDatas, item.name, item.data);
- }
-
- }
- }
- })
- },
- methods: {
- chooseClick: function (item) {
- var that = this;
- var winSetting = {
- "title": item.desc + "选择",
- "width": "1024",
- "height": "80%",
- "url": "/apps?destination=" + item.dataService
- };
- space.plugins.layer.openPredefinePage(winSetting, {
- "success": function (win) {
- win.chooseObj = that.chooseDatas[item.name];
- win.chooseCallback = function (data) {
- var ids = [];
- data.forEach(function (item) {
- ids.push(item.id)
- })
- Vue.set(that.obj, item.name, ids);
- Vue.set(that.chooseDatas, item.name, data);
- }
- }
- });
- },
- removeSelectTag: function (item) {
- var newAry = [];
- var that = this;
- var obj = that.obj[item.name];
- var option = that.chooseDatas[item.name];
- for (let index = 0; index < option.length; index++) {
- var ele = option[index];
- if (obj.indexOf(ele.id) != -1) {
- newAry.push(ele)
- }
- }
- Vue.set(that.chooseDatas, item.name, newAry);
- },
- submit: function () {
-
- space.plugins.loading.show();
- this.removeFlowAllCondition();
- var that = this;
- var errorMsg = "";
- that.conditionData.forEach(function (item) {
- if (!that.obj[item.name] || that.obj[item.name].length == 0) {
- return;
- }
- var additional = "";
- var value = that.obj[item.name];
- if (item.ui == "select") {
- additional = JSON.stringify(that.obj[item.name]);
- value = that.obj[item.name].join();
- }
- if (item.ui == "spaceSelect") {
- additional = JSON.stringify(that.chooseDatas[item.name]);
- value = that.obj[item.name].join();
- }
- var url = '@service{ name: `basic_flow_condition_add`, params:`{mkid: "${mkid}", flowId: "${flowId}"}` }@';
- $.ajax({
- type: "post",
- url: url,
- data: {
- "name": item.name,
- "value": value,
- "additional": additional
- },
- async: false,
- cache: false,
- dataType: 'json',
- success: function (data) {
- if (data.code != 'success') {
- if (space.utils.isNull(errorMsg)) {
- errorMsg = item.desc;
- }
- else {
- errorMsg += "、" + item.desc;
- }
- }
- }
- });
- });
- space.plugins.loading.close();
- if (space.utils.notNull(errorMsg)) {
- space.message.error("以下条件保存失败,请稍后重试:" + errorMsg);
- } else {
- top.spaceIndex.info.success("保存成功", "成功");
- space.allFunction.closeDialog();
- }
- },
- /**
- * 删除流程全部条件
- */
- removeFlowAllCondition: function () {
- var url = '@service{ name: `basic_flow_condition_del`, params:`{mkid: "${mkid}", flowId: "${flowId}"}` }@';
- $.ajax({
- type: "post",
- url: url,
- async: false,
- cache: false,
- dataType: 'json',
- });
- }
- }
- })
- </script>
- </html>
|