1000810518_edit.jsp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <html>
  2. <head>
  3. <style>
  4. .tipsIcon {
  5. font-size: 20px;
  6. color: #aaa;
  7. cursor: pointer;
  8. position: absolute;
  9. right: -29px;
  10. top: 10px;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <div id="space-content">
  16. <div class="space-form-infor">
  17. <el-form action="" method="post" :model="obj" ref="obj" label-width="102px">
  18. <el-form-item :label="item.desc" v-for="(item, index) in conditionData">
  19. <!-- 共四种表单类型项,input、number、spaceSelect、select -->
  20. <el-input v-if="item.ui == 'input'" clearable v-model="obj[item.name]"></el-input>
  21. <el-input v-else-if="item.ui == 'number'" clearable type="number" v-model="obj[item.name]"
  22. placeholder="请输入数字"></el-input>
  23. <el-cascader v-else-if="item.ui == 'select'" v-model="obj[item.name]"
  24. :options="options[item.name + '_options']" :props="props" clearable style="width: 100%;">
  25. </el-cascader>
  26. <space-select v-else-if="item.ui == 'spaceSelect' && space.utils.isNull(item.dataService)"
  27. v-model="obj[item.name]" :predefine="item.name.replace('predefine_','')" datasize="*">
  28. </space-select>
  29. <div class="space-select"
  30. v-else-if="item.ui == 'spaceSelect' && space.utils.notNull(item.dataService)">
  31. <el-select class="choose-obj" v-model="obj[item.name]" multiple placeholder="请选择" clearable
  32. :popper-append-to-body="false" style="width: calc(100% - 60px);"
  33. :disabled="!obj[item.name].length>0" @remove-tag="removeSelectTag(item)"
  34. @clear="removeSelectTag(item)">
  35. <el-option v-for="optionItem in chooseDatas[item.name]" :key="optionItem.id"
  36. :label="optionItem.name" :value="optionItem.id">
  37. </el-option>
  38. </el-select>
  39. <el-button type="button" size="medium" class="choose-btn" icon="el-icon-search"
  40. @click="chooseClick(item)"></el-button>
  41. <div v-for="optionItem in obj[item.name]">{{optionItem.name}}</div>
  42. </div>
  43. <!-- 提示语 -->
  44. <el-tooltip v-if="item.tips" effect="dark" :content="item.tips" placement="left">
  45. <i class="el-icon-warning-outline tipsIcon"></i>
  46. </el-tooltip>
  47. </el-form-item>
  48. </el-form>
  49. </div>
  50. <div class="space-form-btn">
  51. <el-button type="primary" icon="el-icon-circle-check" :loading="loading" @click="submit">保存</el-button>
  52. <el-button icon="el-icon-circle-close" onclick="space.allFunction.closeDialog();">关闭</el-button>
  53. </div>
  54. </div>
  55. </body>
  56. <script type="text/javascript">
  57. var conditionList = '${conditionList}';
  58. var valList = '${valList}';
  59. space.vue = new Vue({
  60. el: space.appContent,
  61. data: function () {
  62. return {
  63. conditionData: space.utils.isNull(conditionList) ? [] : JSON.parse(conditionList),
  64. obj: {},
  65. options: {}, //select下拉
  66. props: { multiple: true }, //select多选
  67. chooseDatas: {}, //spaceSelect 选中的options
  68. loading: false,
  69. valueList: space.utils.isNull(valList) ? [] : JSON.parse(valList), //回显数据
  70. }
  71. },
  72. created: function () {
  73. var that = this;
  74. that.conditionData.forEach(function (item) {
  75. Vue.set(that.obj, item.name, "");
  76. if (item.ui == "select" && space.utils.notNull(item.dataService)) {
  77. space.utils.ajax({
  78. url: "/apps?ark=" + item.dataService,
  79. dataType: 'json',
  80. callback: function (data) {
  81. if (data.code != "success") {
  82. space.message.warning("接口错误");
  83. return;
  84. }
  85. Vue.set(that.options, item.name + "_options", data.data);
  86. }
  87. })
  88. }
  89. });
  90. // 数据回显
  91. that.valueList.forEach(function (item, index) {
  92. that.obj[item.name] = item.val;
  93. if (item.data) {
  94. item.data = JSON.parse(item.data.replace(/"/g, "\""));
  95. // 判断ui表单类型项
  96. if (item.ui == "select") { //select选择器
  97. Vue.set(that.obj, item.name, item.data);
  98. } else if (item.ui == "spaceSelect") { //对象选择器
  99. var valAry = item.val.split(',').map(Number); //将数字字符串转为 数字数组
  100. Vue.set(that.obj, item.name, valAry);
  101. if(item.name.indexOf("predefine_") < 0) { //非预定义 对象选择器
  102. Vue.set(that.chooseDatas, item.name, item.data);
  103. }
  104. }
  105. }
  106. })
  107. },
  108. methods: {
  109. chooseClick: function (item) {
  110. var that = this;
  111. var winSetting = {
  112. "title": item.desc + "选择",
  113. "width": "1024",
  114. "height": "80%",
  115. "url": "/apps?destination=" + item.dataService
  116. };
  117. space.plugins.layer.openPredefinePage(winSetting, {
  118. "success": function (win) {
  119. win.chooseObj = that.chooseDatas[item.name];
  120. win.chooseCallback = function (data) {
  121. var ids = [];
  122. data.forEach(function (item) {
  123. ids.push(item.id)
  124. })
  125. Vue.set(that.obj, item.name, ids);
  126. Vue.set(that.chooseDatas, item.name, data);
  127. }
  128. }
  129. });
  130. },
  131. removeSelectTag: function (item) {
  132. var newAry = [];
  133. var that = this;
  134. var obj = that.obj[item.name];
  135. var option = that.chooseDatas[item.name];
  136. for (let index = 0; index < option.length; index++) {
  137. var ele = option[index];
  138. if (obj.indexOf(ele.id) != -1) {
  139. newAry.push(ele)
  140. }
  141. }
  142. Vue.set(that.chooseDatas, item.name, newAry);
  143. },
  144. submit: function () {
  145. space.plugins.loading.show();
  146. this.removeFlowAllCondition();
  147. var that = this;
  148. var errorMsg = "";
  149. that.conditionData.forEach(function (item) {
  150. if (!that.obj[item.name] || that.obj[item.name].length == 0) {
  151. return;
  152. }
  153. var additional = "";
  154. var value = that.obj[item.name];
  155. if (item.ui == "select") {
  156. additional = JSON.stringify(that.obj[item.name]);
  157. value = that.obj[item.name].join();
  158. }
  159. if (item.ui == "spaceSelect") {
  160. additional = JSON.stringify(that.chooseDatas[item.name]);
  161. value = that.obj[item.name].join();
  162. }
  163. var url = '@service{ name: `basic_flow_condition_add`, params:`{mkid: "${mkid}", flowId: "${flowId}"}` }@';
  164. $.ajax({
  165. type: "post",
  166. url: url,
  167. data: {
  168. "name": item.name,
  169. "value": value,
  170. "additional": additional
  171. },
  172. async: false,
  173. cache: false,
  174. dataType: 'json',
  175. success: function (data) {
  176. if (data.code != 'success') {
  177. if (space.utils.isNull(errorMsg)) {
  178. errorMsg = item.desc;
  179. }
  180. else {
  181. errorMsg += "、" + item.desc;
  182. }
  183. }
  184. }
  185. });
  186. });
  187. space.plugins.loading.close();
  188. if (space.utils.notNull(errorMsg)) {
  189. space.message.error("以下条件保存失败,请稍后重试:" + errorMsg);
  190. } else {
  191. top.spaceIndex.info.success("保存成功", "成功");
  192. space.allFunction.closeDialog();
  193. }
  194. },
  195. /**
  196. * 删除流程全部条件
  197. */
  198. removeFlowAllCondition: function () {
  199. var url = '@service{ name: `basic_flow_condition_del`, params:`{mkid: "${mkid}", flowId: "${flowId}"}` }@';
  200. $.ajax({
  201. type: "post",
  202. url: url,
  203. async: false,
  204. cache: false,
  205. dataType: 'json',
  206. });
  207. }
  208. }
  209. })
  210. </script>
  211. </html>