From 51a43af10043371d434f0cb14a9e75b9d122eb40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=83=91=E7=9A=87?= <236220500@qq.com>
Date: Thu, 2 Dec 2021 17:00:50 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
frontend/src/views/system/dept/form copy.vue | 263 -----------
frontend/src/views/system/dept/form.vue | 254 ++++++++++-
frontend/src/views/system/dept/index.vue | 441 ++++++++++++++++++-
frontend/src/views/system/dept/index2.vue | 423 ------------------
4 files changed, 665 insertions(+), 716 deletions(-)
delete mode 100644 frontend/src/views/system/dept/form copy.vue
delete mode 100644 frontend/src/views/system/dept/index2.vue
diff --git a/frontend/src/views/system/dept/form copy.vue b/frontend/src/views/system/dept/form copy.vue
deleted file mode 100644
index 63967d4..0000000
--- a/frontend/src/views/system/dept/form copy.vue
+++ /dev/null
@@ -1,263 +0,0 @@
-
-
-
-
-
- {{
- $t("commons.catalogue")
- }}
- {{ $t("commons.menu") }}
- {{
- $t("commons.button")
- }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{
- $t("commons.reset")
- }}
- {{ $t("commons.confirm") }}
-
-
-
-
-
-
diff --git a/frontend/src/views/system/dept/form.vue b/frontend/src/views/system/dept/form.vue
index 4a13c2c..7bc5040 100644
--- a/frontend/src/views/system/dept/form.vue
+++ b/frontend/src/views/system/dept/form.vue
@@ -1,26 +1,244 @@
-
+
+
+
+
+
+
+
+
+
+
+ {{ $t('commons.yes') }}
+ {{ $t('commons.no') }}
+
+
+
+
+
+
+ {{ $t('commons.reset') }}
+ {{ $t('commons.confirm') }}
+
+
+
-
+ created() {
+ if (this.$router.currentRoute.params && this.$router.currentRoute.params.deptId) {
+ var row = this.$router.currentRoute.params
+ this.edit(row)
+ } else {
+ this.create()
+ }
+ this.setLoyoutInfo()
+ },
+ mounted() {
+ this.bindKey()
+ },
+ destroyed() {
+ this.unBindKey()
+ },
+ methods: {
+ entryKey(event) {
+ var keyCode = event.keyCode
+ if (keyCode === 13) {
+ this.save()
+ }
+ },
+ bindKey() {
+ document.addEventListener('keypress', this.entryKey)
+ },
+ unBindKey() {
+ document.removeEventListener('keypress', this.entryKey)
+ },
+ executeAxios(url, type, data, callBack) {
+ var param = {
+ url: url,
+ type: type,
+ data: data,
+ callBack: callBack
+ }
+ execute(param)
+ .then(function(res) {
+ if (param.callBack) {
+ param.callBack(res)
+ }
+ })
+ .catch(function(e) {
+ if (param.error) {
+ param.error(e)
+ }
+ })
+ },
+ setLoyoutInfo() {
+ this.$emit('on-plugin-layout', {
+ header: this.formType === 'add' ? this.$t('organization.create') : this.$t('organization.modify'),
+ backName: 'system-dept'
+ })
+ },
+ create() {
+ this.formType = 'add'
+ this.form = Object.assign({}, this.defaultForm)
+ },
+ edit(row) {
+ this.formType = 'modify'
+ this.form = Object.assign({}, row)
+ this.initDeptTree()
+ },
+ initDeptTree() {
+ var _this = this
+ this.executeAxios('/plugin/dept/nodesByDeptId/' + (this.form.pid || 0), 'post', {}, function(res) {
+ var results = res.data.map(function(node) {
+ if (node.hasChildren && !node.children) {
+ node.children = null
+ }
+ return node
+ })
+ _this.depts = results
+ })
+ },
+ // 获取弹窗内部门数据
+ loadDepts(_ref) {
+ var action = _ref.action
+ var parentNode = _ref.parentNode
+ var callback = _ref.callback
+
+ if (action === 'LOAD_ROOT_OPTIONS' && !this.form.pid) {
+ var _self = this
+ this.executeAxios('/plugin/dept/nodesByDeptId/' + 0, 'post', {}, function(res) {
+ var results = res.data.map(function(node) {
+ if (node.hasChildren && !node.children) {
+ node.children = null
+ }
+ return node
+ })
+ _self.depts = _self.excludeSelf(results)
+ callback()
+ })
+ }
+
+ if (action === 'LOAD_CHILDREN_OPTIONS') {
+ var _self2 = this
+ this.executeAxios('/plugin/dept/childNodes/' + parentNode.id, 'post', {}, function(res) {
+ var kids = res.data.map(function(obj) {
+ return _self2.normalizer(obj)
+ })
+
+ parentNode.children = _self2.excludeSelf(kids)
+ callback()
+ })
+ }
+ },
+ normalizer(node) {
+ if (node.hasChildren) {
+ node.children = null
+ }
+ return {
+ id: node.deptId,
+ label: node.name,
+ children: node.children
+ }
+ },
+ topChange(value) {
+ if (!value) {
+ this.form.pid = null
+ this.depts = null
+ this.pLabel = this.$t('dept.root_org')
+ }
+ },
+ reset() {
+ if (this.formType !== 'add') {
+ var row = this.$router.currentRoute.params
+ this.edit(row)
+ } else {
+ this.$refs.deptForm.resetFields()
+ }
+ },
+ save() {
+ var _this2 = this
+
+ this.$refs.deptForm.validate(function(valid) {
+ if (valid) {
+ var url = _this2.formType === 'add' ? '/plugin/dept/create' : '/plugin/dept/update'
+ _this2.executeAxios(url, 'post', _this2.form, function(res) {
+ if (res.data && res.data === -2) {
+ var msg = _this2.pLabel + _this2.$t('dept.name_exist_pre') + _this2.form.name + _this2.$t('dept.name_exist_suf')
+ _this2.$warning(msg)
+ return
+ }
+ _this2.$success(_this2.$t('commons.save_success'))
+ _this2.backToList()
+ })
+ } else {
+ return false
+ }
+ })
+ },
+ backToList() {
+ this.$router.push({ name: 'system-dept' })
+ },
+ excludeSelf(nodes) {
+ var _this3 = this
+
+ if (this.formType !== 'modify') return nodes
+ nodes.forEach(function(node) {
+ return node.id === _this3.form.deptId && (node.isDisabled = true)
+ })
+ return nodes
+ },
+ nodeChange(node, instanceId) {
+ if (node.label) {
+ this.pLabel = node.label
+ }
+ // console.log(node)
+ console.log(instanceId)
+ }
+ }
+}
+
diff --git a/frontend/src/views/system/dept/index.vue b/frontend/src/views/system/dept/index.vue
index 6d9db43..9fd5073 100644
--- a/frontend/src/views/system/dept/index.vue
+++ b/frontend/src/views/system/dept/index.vue
@@ -1,26 +1,443 @@
-
+
+
+
+ {{ $t("organization.create") }}
+
+
+
+
+
+
+
+
+ {{ scope.row.name }}
+
+
+
+
+
+
+
+ {{ scope.row.createTime | timestampFormatDate }}
+
+
+
+
+
+
+
+
diff --git a/frontend/src/views/system/dept/index2.vue b/frontend/src/views/system/dept/index2.vue
deleted file mode 100644
index 3b96c36..0000000
--- a/frontend/src/views/system/dept/index2.vue
+++ /dev/null
@@ -1,423 +0,0 @@
-
-
-
-
- {{ $t("organization.create") }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-