Просмотр исходного кода

更改对话框,集成通用接口、地点层级、所有部门用户信息,用户地点显示

cyy 2 лет назад
Родитель
Сommit
d1632958f7

+ 12 - 1
.vscode/settings.json

@@ -12,5 +12,16 @@
   "search.exclude": {
     "**/dist": true,
     "**/static": true
-  }
+  },
+  "workbench.colorCustomizations": {
+    "activityBar.background": "#332A3A",
+    "titleBar.activeBackground": "#473B52",
+    "titleBar.activeForeground": "#FBFAFB"
+  },
+  "eslint.enable": true,
+  "editor.codeActionsOnSave": {
+    "source.fixAll": true,
+    "source.fixAll.eslint": true
+  },
+  "editor.formatOnSave": true
 }

+ 94 - 0
package-lock.json

@@ -2217,6 +2217,7 @@
         "thread-loader": "^2.1.3",
         "url-loader": "^2.2.0",
         "vue-loader": "^15.9.2",
+        "vue-loader-v16": "npm:vue-loader@^16.0.0-beta.7",
         "vue-style-loader": "^4.1.2",
         "webpack": "^4.0.0",
         "webpack-bundle-analyzer": "^3.8.0",
@@ -5297,6 +5298,11 @@
         "randomfill": "^1.0.3"
       }
     },
+    "crypto-js": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
+      "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+    },
     "css": {
       "version": "2.2.4",
       "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz",
@@ -15577,6 +15583,94 @@
         }
       }
     },
+    "vue-loader-v16": {
+      "version": "npm:vue-loader@16.8.3",
+      "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.3.tgz",
+      "integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
+      "dev": true,
+      "optional": true,
+      "requires": {
+        "chalk": "^4.1.0",
+        "hash-sum": "^2.0.0",
+        "loader-utils": "^2.0.0"
+      },
+      "dependencies": {
+        "ansi-styles": {
+          "version": "4.3.0",
+          "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+          "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "color-convert": "^2.0.1"
+          }
+        },
+        "chalk": {
+          "version": "4.1.2",
+          "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
+          "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "ansi-styles": "^4.1.0",
+            "supports-color": "^7.1.0"
+          }
+        },
+        "color-convert": {
+          "version": "2.0.1",
+          "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+          "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "color-name": "~1.1.4"
+          }
+        },
+        "color-name": {
+          "version": "1.1.4",
+          "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+          "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+          "dev": true,
+          "optional": true
+        },
+        "has-flag": {
+          "version": "4.0.0",
+          "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+          "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+          "dev": true,
+          "optional": true
+        },
+        "json5": {
+          "version": "2.2.3",
+          "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
+          "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
+          "dev": true,
+          "optional": true
+        },
+        "loader-utils": {
+          "version": "2.0.4",
+          "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz",
+          "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "big.js": "^5.2.2",
+            "emojis-list": "^3.0.0",
+            "json5": "^2.1.2"
+          }
+        },
+        "supports-color": {
+          "version": "7.2.0",
+          "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+          "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "has-flag": "^4.0.0"
+          }
+        }
+      }
+    },
     "vue-qr": {
       "version": "2.3.0",
       "resolved": "https://registry.npmjs.org/vue-qr/-/vue-qr-2.3.0.tgz",

+ 1 - 0
package.json

@@ -25,6 +25,7 @@
     "big.js": "^5.2.2",
     "bpmn-js": "^7.3.0",
     "core-js": "^3.6.5",
+    "crypto-js": "^4.2.0",
     "fastclick": "^1.0.6",
     "hls.js": "^0.14.10",
     "js-cookie": "^2.2.1",

+ 11 - 1
src/business/platform/data/data-template/field-formatter.vue

@@ -1,5 +1,14 @@
 <template>
-  <span class="ibps-data-template-data" v-html="label" />
+  <div>
+    <span class="ibps-data-template-data" v-html="label" />
+    <!-- <div>
+      <div v-for="(item, i) in data" :key="i">
+        <span v-if="item.label">{{ item.label }}</span>
+        <span v-if="item.label">:</span>
+        <span v-if="item.val">{{ item.val }}</span>
+      </div>
+    </div> -->
+  </div>
 </template>
 <script>
 import fecha from '@/utils/fecha'
@@ -58,6 +67,7 @@ export default {
   },
   methods: {
     initData() {
+      console.log(this.labelKey, 'this.labelKeythis.labelKey')
       if (!this.labelKey) return
       const value = this.data[this.labelKey]
       if (this.$utils.isEmpty(value)) {

+ 115 - 57
src/business/platform/data/data-template/template.vue

@@ -40,37 +40,51 @@
         </van-cell>
       </van-cell-group>
       <!--多选 -->
-      <van-checkbox-group ref="checkboxGroup" v-model="checkbox" :max="multiple?0:1">
-        <van-cell-group>
-          <van-cell
-            v-for="(data,index) in dataList"
-            :key="data[valueKey]+index"
-            clickable
-            @click="toggle(data,index)"
-          >
-            <div slot="title">
-              <van-checkbox
-                ref="checkboxes"
-                :name="data[valueKey]"
-              >
-                <field-formatter
-                  :label-key="labelKey"
-                  :data="data"
-                  :template-fields="templateFields"
-                />
-              </van-checkbox>
-            </div>
-            <span
-              v-if="hasChild(data)"
-              slot="right-icon"
+      <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="loadData">
+        <van-checkbox-group ref="checkboxGroup" v-model="checkbox" :max="multiple?0:1">
+          <van-cell-group>
+            <van-cell
+              v-for="(data,index) in dataList"
+              :key="data[valueKey]+index"
+              clickable
               @click="toggle(data,index)"
             >
-              <span class="van-cell__right-icon" />
-              <van-icon name="arrow " class="van-cell__right-icon" />
-            </span>
-          </van-cell>
-        </van-cell-group>
-      </van-checkbox-group>
+              <div slot="title">
+                <van-checkbox
+                  ref="checkboxes"
+                  :name="data[valueKey]"
+                >
+                  <!-- <field-formatter
+                    :label-key="labelKey"
+                    :data="data"
+                    :template-fields="templateFields"
+                  /> -->
+                  <div>
+                    <div v-for="(item, i) in data" :key="i">
+                      <span v-if="item.label">{{ item.label }}</span>
+                      <span v-if="item.label">:</span>
+                      <span v-if="item.val">{{ item.val }}</span>
+                      <tree-popup
+                        :visible="visible"
+                        :selectedData="selectedData"
+                        @close="visible => treeVisible = visible"
+                      />
+                    </div>
+                  </div>
+                </van-checkbox>
+              </div>
+              <span
+                v-if="hasChild(data)"
+                slot="right-icon"
+                @click="toggle(data,index)"
+              >
+                <span class="van-cell__right-icon" />
+                <van-icon name="arrow " class="van-cell__right-icon" />
+              </span>
+            </van-cell>
+          </van-cell-group>
+        </van-checkbox-group>
+      </van-list>
     </van-popup>
 
     <!--点击明细-查看选中的 -->
@@ -127,18 +141,20 @@
 </template>
 
 <script>
-import { queryDataByKey, queryDataById } from '@/api/platform/data/dataTemplate'
+import { queryDataByKey, queryDataById, getByKey } from '@/api/platform/data/dataTemplate'
 import { remoteRequest } from '@/utils/remote'
 import TreeUtils from '@/utils/tree'
 import ActionUtils from '@/utils/action'
 import i18n from '@/utils/i18n' // Internationalization 国际化
 import FieldFormatter from './field-formatter'
 import IbpsPickerToolbar from '@/components/ibps-picker-toolbar'
+import TreePopup from '../../org/selector/popup-tree/index.vue'
 
 export default {
   components: {
     IbpsPickerToolbar,
-    FieldFormatter
+    FieldFormatter,
+    TreePopup
   },
   props: {
     visible: Boolean,
@@ -150,6 +166,7 @@ export default {
     leftText: String,
     searchPlaceholder: String,
     isTree: Boolean,
+    datat: Object,
     idKey: { // 唯一键
       type: String,
       default: 'id_'
@@ -184,9 +201,12 @@ export default {
       displayColumns: [],
 
       checkedValue: [],
-
+      dataTem: {},
       showDialogPopup: false,
-      showDetailPopup: false
+      showDetailPopup: false,
+      page: 1,
+      loading: true,
+      finished: false
     }
   },
   computed: {
@@ -234,6 +254,7 @@ export default {
   },
   methods: {
     initData() {
+      console.log(this.datat, 'dataTemplate')
       const data = this.value
       this.checkedValue = []
       this.checkbox = []
@@ -268,6 +289,7 @@ export default {
       remoteRequest('dataTemplate', params, () => {
         return this.getRemoteDataTemplateByIdFunc(params)
       }).then(responseData => {
+        console.log(responseData, 'responseData')
         if (this.$utils.isNotEmpty(responseData) && this.$utils.isNotEmpty(responseData.data)) {
           const data = responseData.data[0] || {}
           let key = id
@@ -307,30 +329,65 @@ export default {
       if (!this.isTre) {
         pagination = { page: this.page }
       }
-      // TODO: 分页数据处理
-      // 加载数据
-      queryDataByKey(ActionUtils.formatParams(params, pagination)).then(response => {
-        const dataResult = response.data.dataResult
-        if (this.isTree) {
-          this.dataList = TreeUtils.transformToTreeFormat(dataResult, {
-            idKey: this.idKey,
-            parentIdKey: this.parentIdKey,
-            childrenKey: this.childrenKey
-          })
-          // 初始化最顶级数据
-          this.initRootTreeData(response.vars)
-          // 缓存数据
-          dataResult.map((d) => {
-            this.cacheData[d[this.valueKey]] = d
-          })
-        } else {
-          this.dataList = dataResult
-          this.dataList.map((d) => {
-            this.cacheData[d[this.valueKey]] = d
-          })
-        }
-      }).catch((e) => {
-        console.error(e)
+      // console.log(!this.isTre, this.page, 'this.pagethis.page')
+      //
+      getByKey({
+        dataTemplateKey: this.templateKey
+      }).then(response => {
+        this.dataTem = this.$utils.parseData(response.data).templates[0]
+        console.log(this.dataTem, 'dadadadadadada')
+        // this.loadAjaxOptions()
+        // TODO: 分页数据处理
+        // 加载数据
+        queryDataByKey(ActionUtils.formatParams(params, pagination)).then(response => {
+          const dataResult = response.data.dataResult
+          const pageResult = response.data.pageResult
+          if (this.isTree) {
+            this.dataList = TreeUtils.transformToTreeFormat(dataResult, {
+              idKey: this.idKey,
+              parentIdKey: this.parentIdKey,
+              childrenKey: this.childrenKey
+            })
+            // 初始化最顶级数据
+            this.initRootTreeData(response.vars)
+            // 缓存数据
+            dataResult.map((d) => {
+              this.cacheData[d[this.valueKey]] = d
+            })
+          } else {
+            // const mid = []
+            const dl = dataResult
+            dl.map((d) => {
+              this.cacheData[d[this.valueKey]] = d
+              const objName = Object.keys(d)
+              const fb = {}
+              objName.forEach((it, i) => {
+                let b = {}
+                const keyName = this.dataTem.display_columns.find(t => t.name === it)
+                if (typeof keyName !== 'undefined' && keyName) {
+                  b = { 'label': keyName.label, 'val': d[it] }
+                } else {
+                  b = d[it]
+                }
+                fb[it] = b
+              })
+              this.dataList.push(fb)
+            })
+            // this.dataList = [this.dataList, ...mid]
+            // console.log(this.dataList, 'this.dataList')
+          }
+          this.page++
+          // 加载状态结束
+          this.loading = false
+          console.log(this.dataList.length >= pageResult.totalCount, this.page > pageResult.totalPages)
+          // 数据全部加载完成
+          if (this.dataList.length >= pageResult.totalCount || this.page > pageResult.totalPages) {
+            this.finished = true
+          }
+        }).catch((e) => {
+          console.error(e)
+        })
+      }).catch(() => {
       })
     },
     /**
@@ -343,6 +400,7 @@ export default {
         [this.labelKey]: vars.rootLabel || '顶级',
         [this.childrenKey]: this.dataList
       }
+      console.log(this.dataList, 'this.dataList')
       this.pathData.push(data)
     },
 

+ 1 - 1
src/business/platform/data/templaterender/custom-dialog/index.vue

@@ -207,7 +207,7 @@ export default {
         }
       } else if (dataTemplate.showType === 'list') {
         this.isTree = false
-        const displayColumns = template['display_columns']
+        const displayColumns = template['result_columns']
         if (this.$utils.isNotEmpty(displayColumns)) {
           this.labelKey = (displayColumns[0] ? displayColumns[0]['name'] : '') || ''
         }

+ 50 - 33
src/business/platform/form/utils/JForm.js

@@ -8,98 +8,115 @@
  * 版权:广州流辰信息技术有限公司
  * </pre>
  */
-import _ from 'lodash'
-import request from '@/utils/request'
+import _ from "lodash";
+import request from "@/utils/request";
 
 // 定义全局
-var JForm
+var JForm;
 if (!window.JForm) {
-  JForm = window.JForm = {}
+  JForm = window.JForm = {};
 } else {
-  JForm = window.JForm
+  JForm = window.JForm;
 }
 /**
-   * 封装自定义代码扩展接口
-   */
+ * 封装自定义代码扩展接口
+ */
 _.extend(JForm, {
   // 已经初始化
+  _request: request,
   _isInitialization: false,
   _isLoadJavaScriptFile: false,
   // 初始化表单
   _init: function(form) {
-    if (this._isInitialization) return
-    this.$form = form
-    this.$request = request
-    this._isInitialization = true
+    if (this._isInitialization) return;
+    this.$form = form;
+    this.$request = request;
+    this._isInitialization = true;
   },
 
   // 表单加载
   _onLoad: function(form) {
-    this._init(form)
+    this._init(form);
     if (_.isFunction(this.onLoad)) {
-      this.onLoad(form)
+      this.onLoad(form);
     }
   },
 
   // 加载按钮
   _onLoadActions: function(form, actions) {
     if (_.isFunction(this.onLoadActions)) {
-      this.onLoadActions(form, actions)
+      this.onLoadActions(form, actions);
     }
   },
 
   // 表单校验
   _onValidate: function(form, callback) {
     if (_.isFunction(this.onValidate)) {
-      return this.onValidate(form, callback)
+      return this.onValidate(form, callback);
+    }
+    if (_.isFunction(callback)) {
+      callback(true);
     }
-    if (_.isFunction(callback)) { callback(true) }
   },
 
   // 按钮提交前事件
   _beforeSubmit: function(form, action, postValue, callback) {
     if (_.isFunction(this.beforeSubmit)) {
-      return this.beforeSubmit(form, action, postValue, callback)
+      return this.beforeSubmit(form, action, postValue, callback);
+    }
+    if (_.isFunction(callback)) {
+      callback(true);
     }
-    if (_.isFunction(callback)) { callback(true) }
   },
 
   // 按钮提交后事件
   _afterSubmit: function(form, action, postValue, callback) {
     if (_.isFunction(this.afterSubmit)) {
-      return this.afterSubmit(form, action, postValue, callback)
+      return this.afterSubmit(form, action, postValue, callback);
+    }
+    if (_.isFunction(callback)) {
+      callback(true);
     }
-    if (_.isFunction(callback)) { callback(true) }
   },
   // 子表按钮的提交前事件
   _beforeSubButton: function(tableForm, action, position, params, callback) {
     if (_.isFunction(this.beforeSubButton)) {
-      return this.beforeSubButton(tableForm, action, position, params, callback)
+      return this.beforeSubButton(
+        tableForm,
+        action,
+        position,
+        params,
+        callback
+      );
+    }
+    if (_.isFunction(callback)) {
+      callback(true);
     }
-    if (_.isFunction(callback)) { callback(true) }
   },
   // 子表按钮的提交后事件
   _afterSubButton: function(tableForm, action, position, params, callback) {
     if (_.isFunction(this.afterSubButton)) {
-      return this.afterSubButton(tableForm, action, position, params, callback)
+      return this.afterSubButton(tableForm, action, position, params, callback);
+    }
+    if (_.isFunction(callback)) {
+      callback(true);
     }
-    if (_.isFunction(callback)) { callback(true) }
   },
   // 子表统计
   _summaryMethod: function(tableForm, tableName, params) {
     if (_.isFunction(this.summaryMethod)) {
-      return this.summaryMethod(tableForm, tableName, params)
+      return this.summaryMethod(tableForm, tableName, params);
     }
   },
   // 清理所有自定义事件
   cleanEvents: function() {
-    this.onLoad = null
-    this.onLoadActions = null
-    this.onValidate = null
-    this.afterSubButton = null
-    this.beforeSubButton = null
-    this._isInitialization = false
+    this.onLoad = null;
+    this.onLoadActions = null;
+    this.onValidate = null;
+    this.afterSubButton = null;
+    this.beforeSubButton = null;
+    this._isInitialization = false;
   }
-})
+});
 
-export default JForm
+export default JForm;

+ 28 - 26
src/main.js

@@ -1,45 +1,47 @@
 // 全局css样式
-import 'normalize.css'
-import 'vant/lib/index.less'
-import 'vant/lib/icon/local.css'
-import '@/assets/fonts/ibps-icon.scss'
+import "normalize.css";
+import "vant/lib/index.less";
+import "vant/lib/icon/local.css";
+import "@/assets/fonts/ibps-icon.scss";
 
-import Vue from 'vue'
+import Vue from "vue";
 // 移动端调试
 // import Vconsole from 'vconsole'
 // const vConsole = new Vconsole()
 // Vue.use(vConsole)
 
-import App from './App'
-import router from './router'
-import store from './store'
-import './errorLog' // error log 错误日志
-import i18n from './i18n' // Internationalization 国际化
-import utils from './utils/util' // utils 帮助类
-import env from '@/env'
-import ActionUtils from '@/utils/action'
+import App from "./App";
+import router from "./router";
+import store from "./store";
+import "./errorLog"; // error log 错误日志
+import i18n from "./i18n"; // Internationalization 国际化
+import utils from "./utils/util"; // utils 帮助类
+import request from "./utils/joinCURD"; // 通用请求
+import env from "@/env";
+import ActionUtils from "@/utils/action";
 
-import Vant from 'vant'
+import Vant from "vant";
 
-Vue.use(Vant) // 导入vant
-Vue.prototype.$action = ActionUtils // 全局action
-Vue.prototype.$utils = utils // 全局帮助类
+Vue.use(Vant); // 导入vant
+Vue.prototype.$action = ActionUtils; // 全局action
+Vue.prototype.$utils = utils; // 全局帮助类
+Vue.prototype.$request = request; // 通用请求
 // 基础路径
-Vue.prototype.$baseUrl = process.env.VUE_APP_PUBLIC_PATH || '/'
+Vue.prototype.$baseUrl = process.env.VUE_APP_PUBLIC_PATH || "/";
 // 当前环境
-Vue.prototype.$nodeEnv = process.env.NODE_ENV
+Vue.prototype.$nodeEnv = process.env.NODE_ENV;
 // 当前环境变量
-Vue.prototype.$env = env
+Vue.prototype.$env = env;
 
-import * as filters from './filters' // global filters 全局过滤
+import * as filters from "./filters"; // global filters 全局过滤
 // register global utility filters. 注册全局过滤器
 Object.keys(filters).forEach(key => {
-  Vue.filter(key, filters[key])
-})
+  Vue.filter(key, filters[key]);
+});
 /**
  *  日志输出开关
  */
-Vue.config.productionTip = false
+Vue.config.productionTip = false;
 /**
  *  创建实例
  */
@@ -49,7 +51,7 @@ new Vue({
   i18n,
   async created() {
     // 加载接口配置
-    await this.$store.dispatch('ibps/api/load')
+    await this.$store.dispatch("ibps/api/load");
   },
   render: h => h(App)
-}).$mount('#app')
+}).$mount("#app");

+ 36 - 7
src/store/getters.js

@@ -1,10 +1,25 @@
 export default {
   // 用户相关
-  userId: state => state.ibps.user.info && state.ibps.user.info.user ? state.ibps.user.info.user.id : '', // 用户ID
-  userName: state => state.ibps.user.info && state.ibps.user.info.employee ? state.ibps.user.info.employee.name : '', // 姓名
-  status: state => state.ibps.user.info && state.ibps.user.info.employee ? state.ibps.user.info.employee.status : '', // 用户状态
-  isSuper: state => state.ibps.user.info && state.ibps.user.info.user ? state.ibps.user.info.user.isSuper === 'Y' : false, // 是否超级管理员
-  account: state => state.ibps.user.info && state.ibps.user.info.user ? state.ibps.user.info.user.account : '', // 用户名
+  userId: state =>
+    state.ibps.user.info && state.ibps.user.info.user
+      ? state.ibps.user.info.user.id
+      : "", // 用户ID
+  userName: state =>
+    state.ibps.user.info && state.ibps.user.info.employee
+      ? state.ibps.user.info.employee.name
+      : "", // 姓名
+  status: state =>
+    state.ibps.user.info && state.ibps.user.info.employee
+      ? state.ibps.user.info.employee.status
+      : "", // 用户状态
+  isSuper: state =>
+    state.ibps.user.info && state.ibps.user.info.user
+      ? state.ibps.user.info.user.isSuper === "Y"
+      : false, // 是否超级管理员
+  account: state =>
+    state.ibps.user.info && state.ibps.user.info.user
+      ? state.ibps.user.info.user.account
+      : "", // 用户名
 
   regOpen: state => state.ibps.user.regOpen, // 注册状态
 
@@ -17,5 +32,19 @@ export default {
 
   single: state => state.ibps.api.single, // 单体应用
   baseApi: state => state.ibps.api.base, // baseAPI地址
-  websocket: state => state.ibps.api.websocket // websocket地址
-}
+  websocket: state => state.ibps.api.websocket, // websocket地址
+
+  // 获取所有用户信息
+  userList: state =>
+    state.ibps.param && state.ibps.param.userList
+      ? state.ibps.param.userList
+      : [],
+  // 获取所有部门信息
+  deptList: state =>
+    state.ibps.param && state.ibps.param.deptList
+      ? state.ibps.param.deptList
+      : [],
+  // 获取用户最高层级
+  level: state =>
+    state.ibps.param && state.ibps.param.level ? state.ibps.param.level : []
+};

+ 49 - 0
src/store/modules/ibps/modules/param.js

@@ -0,0 +1,49 @@
+export default {
+    namespaced: true,
+    state: {
+        // 所有菜单
+        myform: '',
+        // 所有用户信息
+        userList: [],
+        // 所有部门信息
+        deptList: [],
+        pitchDept: [],
+        // 当前用户层级
+        level: {
+            first: '',
+            second: ''
+        }
+    },
+    mutations: {
+        myformSet (state, myform) {
+            state.myform = myform.myform || ''
+        },
+        userList (state, data) {
+            state.userList = data.length ? data : []
+        },
+        deptList (state, data) {
+            state.deptList = data.length ? data : []
+        },
+        pitchDept (state, data) {
+            state.pitchDept = data.length ? data : []
+        },
+        level (state, data) {
+            state.level = data || { first: '', second: '' }
+        }
+    },
+    actions: {
+        setUserList ({ commit }, data) {
+            commit('userList', data)
+        },
+        setDeptList ({ commit }, data) {
+            commit('deptList', data)
+        },
+        setpitchDept ({ commit }, data) {
+            commit('pitchDept', data)
+        },
+        setLevel ({ commit }, data) {
+            console.log(data)
+            commit('level', data)
+        }
+    }
+}

+ 149 - 60
src/store/modules/ibps/modules/user.js

@@ -1,4 +1,5 @@
-import { getUserInfo } from '@/api/oauth2/user'
+import { getUserInfo } from "@/api/oauth2/user";
+import common from "@/utils/joinCURD";
 
 export default {
   namespaced: true,
@@ -6,9 +7,9 @@ export default {
     // 用户信息
     info: {},
     // 帐号
-    account: '',
+    account: "",
     // 切换的账号
-    switchAccount: '',
+    switchAccount: "",
     // 是否开启注册
     regOpen: false
   },
@@ -21,17 +22,21 @@ export default {
     set({ state, dispatch }, info) {
       return new Promise(async resolve => {
         // store 赋值
-        state.info = info
+        state.info = info;
         // 持久化
-        await dispatch('ibps/db/set', {
-          dbName: 'sys',
-          path: 'user.info',
-          value: info,
-          user: true
-        }, { root: true })
+        await dispatch(
+          "ibps/db/set",
+          {
+            dbName: "sys",
+            path: "user.info",
+            value: info,
+            user: true
+          },
+          { root: true }
+        );
         // end
-        resolve()
-      })
+        resolve();
+      });
     },
     /**
      * @description 从数据库取用户数据
@@ -40,39 +45,72 @@ export default {
     get({ state, dispatch }) {
       return new Promise(async resolve => {
         // store 赋值
-        state.info = await dispatch('ibps/db/get', {
-          dbName: 'sys',
-          path: 'user.info',
-          defaultValue: {},
-          user: true
-        }, { root: true })
+        state.info = await dispatch(
+          "ibps/db/get",
+          {
+            dbName: "sys",
+            path: "user.info",
+            defaultValue: {},
+            user: true
+          },
+          { root: true }
+        );
         // end
-        resolve()
-      })
+        resolve();
+      });
     },
     /**
      * @description 从数据库取用户数据
      * @param {Object} context
      */
     load({ state, dispatch }) {
-      return new Promise(async(resolve, reject) => {
-        await dispatch('getAccount')
-        getUserInfo(state.account).then(async response => {
-          if (!response) {
-            reject(response)
-          }
-          const info = response.data
-          // 设置当前
-          await dispatch('set', info)
-          // // 获取当前子系统
-          // await dispatch('ibps/system/loadSystem', null, {
-          //   root: true
-          // })
-          resolve(info)
-        }).catch(error => {
-          reject(error)
-        })
-      })
+      return new Promise(async (resolve, reject) => {
+        await dispatch("getAccount");
+        getUserInfo(state.account)
+          .then(async response => {
+            if (!response) {
+              reject(response);
+            }
+            const info = response.data;
+            // 设置当前
+            await dispatch("set", info);
+            let level = {};
+            if (info.positions && info.positions.length) {
+              // 当存在第二级为空时,说明具备最高级权限
+              const hasFirst = info.positions.some(
+                obj => obj.path.split(".")[1] === ""
+              );
+              level = {
+                first: [
+                  ...new Set(info.positions.map(obj => obj.path.split(".")[0]))
+                ].join(","),
+                second: hasFirst
+                  ? ""
+                  : [
+                      ...new Set(
+                        info.positions.map(obj => obj.path.split(".")[1])
+                      )
+                    ].join(",")
+              };
+              await dispatch("ibps/param/setLevel", level, {
+                root: true
+              });
+            }
+            console.log(level, "infoinfo");
+            // 获取所有用户信息
+            await dispatch("getUserList", level);
+            // 获取所有部门信息
+            await dispatch("getDeptList", level);
+            // // 获取当前子系统
+            // await dispatch('ibps/system/loadSystem', null, {
+            //   root: true
+            // })
+            resolve(info);
+          })
+          .catch(error => {
+            reject(error);
+          });
+      });
     },
     /**
      * 获取用户名
@@ -81,33 +119,84 @@ export default {
     getAccount({ state, dispatch }) {
       return new Promise(async resolve => {
         // store 赋值
-        state.account = await dispatch('ibps/db/get', {
-          dbName: 'sys',
-          path: 'account',
-          defaultValue: '',
-          user: true
-        }, { root: true })
+        state.account = await dispatch(
+          "ibps/db/get",
+          {
+            dbName: "sys",
+            path: "account",
+            defaultValue: "",
+            user: true
+          },
+          { root: true }
+        );
         // end
-        resolve()
-      })
+        resolve();
+      });
     },
-    setAccount({
-      state,
-      dispatch
-    }, account) {
+    setAccount({ state, dispatch }, account) {
       return new Promise(async resolve => {
         // store 赋值
-        state.account = account
+        state.account = account;
         // 持久化
-        await dispatch('ibps/db/set', {
-          dbName: 'sys',
-          path: 'account',
-          value: account,
-          user: true
-        }, { root: true })
+        await dispatch(
+          "ibps/db/set",
+          {
+            dbName: "sys",
+            path: "account",
+            value: account,
+            user: true
+          },
+          { root: true }
+        );
         // end
-        resolve()
-      })
+        resolve();
+      });
+    },
+    /**
+     * 获取所有系统用户账号
+     */
+    getUserList({ state, dispatch }, { first, second }) {
+      const params = second
+        ? `'%${second}%' or entity.id_ = '${first}'`
+        : first
+        ? `'%${first}%'`
+        : "%%";
+      const sql = `select users.id_ as userId, users.name_ as userName, ifnull(users.mobile_, '') as phone, ifnull(group_concat(distinct positions.id_ order by positions.id_ separator ','), '') as positionId, ifnull(group_concat(distinct positions.name_ order by positions.id_ separator ','), '') as positions, ifnull(group_concat(distinct roles.id_ order by roles.role_note_ asc separator ','), '') as roleId, ifnull(group_concat(distinct roles.name_ order by roles.role_note_ asc separator ','), '') as roles, (select ifnull(people.qian_zi_tu_wen_, '') from t_ryjbqk as people where people.parent_id_ = users.id_) as signatureId, (select ifnull(files.file_name_, '') from ibps_file_attachment as files where files.id_ = signatureId) as signatureName from ibps_party_employee as users left join (select ur.user_id_, r.role_note_, group_concat(distinct r.id_ order by r.id_ separator ',') as id_, group_concat(distinct r.name_ order by r.id_ separator ',') as name_ from ibps_party_user_role as ur join ibps_party_role as r on ur.role_id_ = r.id_ group by ur.user_id_) as roles on users.id_ = roles.user_id_ left join ibps_party_entity as positions on find_in_set(positions.id_, users.positions_) where exists (select 1 from ibps_party_entity as entity where find_in_set(entity.id_, users.positions_) and (entity.path_ like ${params})) group by users.id_`;
+      common("sql", sql)
+        .then(res => {
+          const { data = [] } = res.variables || {};
+          dispatch("ibps/param/setUserList", data, {
+            root: true
+          });
+        })
+        .catch(error => {
+          console.log(error);
+          alert("获取所有用户信息失败!");
+        });
+    },
+    /**
+     * 获取所有系统部门信息
+     */
+    getDeptList({ state, dispatch }, { first, second }) {
+      const params = second
+        ? ` and (pe.path_ like '%${second}%' or pe.id_ = '${first}')`
+        : first
+        ? ` and pe.path_ like '%${first}%'`
+        : "";
+      // const sql = `select id_ as positionId, name_ as positionName, path_ as path, depth_ as depth, sn_ as sn from ibps_party_entity where party_type_ = 'position'${params} order by depth_ asc, sn_ asc`
+      const sql = `select pe.id_ as positionId, pe.name_ as positionName, pe.path_ as path, pe.depth_ as depth, pe.sn_ as sn, ifnull(r.name_, '') as manager, ifnull(r.id_, '') as managerId from ibps_party_entity as pe left join (select em.id_, em.positions_, em.name_ from ibps_party_employee as em left join ibps_party_user_role as ur on em.id_ = ur.user_id_ left join ibps_party_role as pr on pr.id_ = ur.role_id_ where role_alias_ in ('zhsfzr', 'syszr', 'zhglzzc')) as r on find_in_set(pe.id_, r.positions_) > 0 where pe.party_type_ = 'position'${params} group by pe.id_ order by pe.depth_ asc, pe.sn_ asc,pe.id_ asc`;
+      common("sql", sql)
+        .then(res => {
+          console.log(res, "sqlsqlsql");
+          const { data = [] } = res.variables || {};
+          dispatch("ibps/param/setDeptList", data, {
+            root: true
+          });
+        })
+        .catch(error => {
+          console.log(error);
+          alert("获取所有部门信息失败!");
+        });
     }
   }
-}
+};

+ 26 - 0
src/utils/encrypt.js

@@ -0,0 +1,26 @@
+import CryptoJS from 'crypto-js'
+const key = CryptoJS.enc.Utf8.parse('dmngJmmO+9GMw+tu')
+const iv = CryptoJS.enc.Utf8.parse('sanXyqhk8+U7LPP4')
+// AES加密
+export const encryptByAes = pwd => {
+    let encrypted = ''
+    if (typeof pwd === 'string') {
+        const srcs = CryptoJS.enc.Utf8.parse(pwd)
+        const options = {
+            iv: iv,
+            mode: CryptoJS.mode.CBC, // 使用CBC模式
+            padding: CryptoJS.pad.Pkcs7 // 使用PKCS7填充
+        }
+        encrypted = CryptoJS.AES.encrypt(srcs, key, options)
+    } else if (typeof pwd === 'object') {
+        const data = JSON.stringify(pwd)
+        const srcs = CryptoJS.enc.Utf8.parse(data)
+        const options = {
+            iv: iv,
+            mode: CryptoJS.mode.CBC, // 使用CBC模式
+            padding: CryptoJS.pad.Pkcs7 // 使用PKCS7填充
+        }
+        encrypted = CryptoJS.AES.encrypt(srcs, key, options)
+    }
+    return encrypted.ciphertext.toString(CryptoJS.enc.Base64)
+}

+ 52 - 0
src/utils/joinCURD.js

@@ -0,0 +1,52 @@
+import request from "./request";
+import { normal } from "./requestType";
+import { encryptByAes } from "./encrypt";
+import { mapValues } from "lodash";
+// 请求方式默认POST
+const post = (type, data, method = "post", loading = false) => {
+  const requestUrl = `business/v3/sys/universal/${normal[type]}`;
+  // 非sql类型要关闭loading动画需传参loading:true
+  const isLoading = type === "sql" ? loading : !loading;
+  return request({
+    url: requestUrl,
+    method,
+    data: dealData(data, type),
+    // 开启表单提交加载,查询接口除外
+    isLoading
+  });
+};
+
+const replaceNullWithEmpty = obj => {
+  function replaceValue(value) {
+    if (value === null) {
+      return "";
+    } else if (typeof value === "object") {
+      if (Array.isArray(value)) {
+        return value.map(item => replaceValue(item));
+      } else {
+        return mapValues(value, v => replaceValue(v));
+      }
+    } else {
+      return value;
+    }
+  }
+  return replaceValue(obj);
+};
+
+// // 处理数据
+const dealData = (args, type) => {
+  // sql方法特殊处理
+  if (type === "sql") {
+    args = {
+      sql: args.replace(/\n/g, " ")
+    };
+  }
+  const data = typeof args === "object" ? replaceNullWithEmpty(args) : args;
+  const res = {
+    ciphertext: encryptByAes(data),
+    plaintext: data
+  };
+  return JSON.stringify(res);
+};
+
+export default post;

+ 8 - 0
src/utils/requestType.js

@@ -0,0 +1,8 @@
+// 通用请求,增删改查
+export const normal = {
+    // sql: 'encipher',
+    sql: 'general',
+    delete: 'batchDelete',
+    add: 'addDataContextTable',
+    update: 'updatesBatchContextTable'
+}

+ 20 - 2
src/views/platform/my/index.vue

@@ -80,9 +80,17 @@ export default {
   },
   mixins: [navbar],
   data() {
+    const { first = '', second = '' } = this.$store.getters.level
+    const { userId, userList = [], deptList = [], menus, userInfo } = this.$store.getters
+    const t1 = deptList.find(i => i.positionId === first) || {}
+    const t2 = deptList.find(i => i.positionId === second) || {}
+    console.log(first, second, deptList)
+    const locationName = second ? t1.positionName + t2.positionName : t1.positionName
     return {
       defaultImage: defaultImage,
-      size: 'large'
+      size: 'large',
+      positionList: [],
+      locationName
     }
   },
   computed: {
@@ -103,7 +111,8 @@ export default {
       return this.info && this.info.user ? this.info.user.fullname : ''
     },
     org() {
-      return this.info && this.info.org ? this.info.org.name : ''
+      console.log(this.locationName, 'this.locationNamethis.locationName')
+      return this.locationName
     },
     position() {
       const positions = this.info && this.info.positions ? this.info.positions : null
@@ -116,6 +125,15 @@ export default {
       return pos.join(',')
     }
   },
+  // created(){
+  //   const sql = `select a.ID_ as ID_, a.NAME_ as NAME_, b.path_ as PATH_ FROM ibps_party_position a, ibps_party_entity b where a.id_ = b.id_`
+  //   console.log(this, 'thisthis')
+  //   this.$request('sql', sql).then((res) => {
+  //     console.log(this.info, res, 'resresresresresresres')
+  //     this.positionList = res.variables.data || []
+  //     // resolve()
+  //   })
+  // },
   methods: {
     userInfo() {
       this.$router.push({ name: 'userInfo' })