From c26deaa0190c0ed42b398f3e5696013127a6c10f Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期二, 11 三月 2025 16:17:51 +0800
Subject: [PATCH] 1.看板修改

---
 src/views/basicSettings/organizationList.vue |  885 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 445 insertions(+), 440 deletions(-)

diff --git a/src/views/basicSettings/organizationList.vue b/src/views/basicSettings/organizationList.vue
index 8a49fa3..7fe1420 100644
--- a/src/views/basicSettings/organizationList.vue
+++ b/src/views/basicSettings/organizationList.vue
@@ -1,440 +1,445 @@
-<template>
-  <div>
-    <div class="body" :style="{height:mainHeight+'px'}">
-      <div class="bodyTopButtonGroup" style="justify-content: space-between">
-        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
-      </div>
-
-      <div class="bodyTopFormGroup">
-        <el-form
-          ref="form"
-          :model="form"
-          label-width="100px"
-          inline
-          style="display: flex;"
-        >
-          <div class="elForm">
-            <el-form-item label="缁勭粐缂栫爜" style=" display: flex;">
-              <el-input v-model="form.storg_code" placeholder="璇疯緭鍏�" style="width: 200px" />
-            </el-form-item>
-            <el-form-item label="缁勭粐鍚嶇О" style=" display: flex;">
-              <el-input v-model="form.storg_name" placeholder="璇疯緭鍏�" style="width: 200px" />
-            </el-form-item>
-          </div>
-          <div
-            class="bodySearchReset"
-            :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
-          >
-            <el-button v-waves type="primary" icon="el-icon-search" @click="getSTorgData">鏌ヨ</el-button>
-            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
-          </div>
-        </el-form>
-        <div
-          class="bodyTopFormExpand"
-          style="height:5px"
-        >
-          <!--          <svg-icon-->
-          <!--            v-show="mouseHoverType==='mouseout'"-->
-          <!--            style="cursor: pointer"-->
-          <!--            :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"-->
-          <!--            @mouseenter="mouseHoverType=$event.type"-->
-          <!--          />-->
-          <!--          <svg-icon-->
-          <!--            v-show="mouseHoverType==='mouseenter'"-->
-          <!--            style="cursor: pointer"-->
-          <!--            :icon-class="!isExpandForm?'doubleDown':'doubleUp'"-->
-          <!--            @click="isExpandForm=!isExpandForm"-->
-          <!--            @mouseout="mouseHoverType=$event.type"-->
-          <!--          />-->
-        </div>
-      </div>
-
-      <div class="elTableDiv">
-        <el-table
-          ref="tableDataRef"
-          class="tableFixed"
-          :data="tableData"
-          :height="tableHeight+'px'"
-          border
-          row-class-name="custom-row"
-          :style="{width: 100+'%',height:tableHeight+'px',}"
-          highlight-current-row
-          row-key="torg_code"
-          default-expand-all
-          :header-cell-style="this.$headerCellStyle"
-          :cell-style="this.$cellStyle"
-          @sort-change="sortChange"
-        >
-          <!--          <el-table-column-->
-          <!--            prop="rowNum"-->
-          <!--            width="120"-->
-          <!--            fixed-->
-          <!--            label="搴忓彿"-->
-          <!--          />-->
-          <el-table-column
-            prop="torg_code"
-            label="缁勭粐缂栫爜"
-            sortable="custom"
-          />
-          <el-table-column
-            prop="torg_name"
-            label="缁勭粐鍚嶇О"
-            sortable="custom"
-          />
-          <el-table-column
-            prop="status"
-            label="鐘舵��"
-            sortable="custom"
-          >
-            <template slot-scope="{row}">
-              <el-tag v-if="row.status==='Y'" size="small" type="success">姝e父</el-tag>
-              <el-tag v-if="row.status==='N'" size="small" type="danger">鍋滅敤</el-tag>
-            </template>
-          </el-table-column>
-          <el-table-column
-            prop="username"
-            label="鍒涘缓浜哄憳"
-            sortable="custom"
-          />
-          <el-table-column
-            prop="lm_date"
-            label="鍒涘缓鏃堕棿"
-            width="160"
-            sortable="custom"
-          />
-          <el-table-column
-            label="鎿嶄綔"
-            width="120"
-            fixed="right"
-          >
-            <template slot-scope="{row}">
-              <div class="operationClass">
-                <el-tooltip class="item" effect="dark" content="缂栬緫" placement="top">
-                  <i
-                    v-if="row.leve!==0"
-                    class="el-icon-edit-outline"
-                    :style="{color:$store.state.settings.theme}"
-                    @click="edit('edit',row)"
-                  />
-                </el-tooltip>
-                <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
-                  <i
-                    v-if="row.leve!==0"
-                    class="el-icon-delete"
-                    :style="{color:$store.state.settings.theme}"
-                    @click="del(row)"
-                  />
-                </el-tooltip>
-              </div>
-            </template>
-          </el-table-column>
-        </el-table>
-      </div>
-      <!--鍒嗛〉-->
-      <!--      <pagination-->
-      <!--        :total="total"-->
-      <!--        :page.sync="form.page"-->
-      <!--        :limit.sync="form.rows"-->
-      <!--        align="right"-->
-      <!--        layout="total,prev, pager, next,sizes,jumper"-->
-      <!--        popper-class="select_bottom"-->
-      <!--        @pagination="getSTorgData"-->
-      <!--      />-->
-    </div>
-
-    <el-dialog
-      v-el-drag-dialog
-      :title="operation==='add'?'鏂板':'缂栬緫'"
-      :visible.sync="dialogVisible"
-      width="800px"
-      :close-on-click-modal="false"
-      top="15vh"
-      @closed="handleClose"
-      @close="handleClose"
-    >
-      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
-        <el-form-item label="缁勭粐缂栫爜" prop="OrganCode">
-          <el-input v-model="dialogForm.OrganCode" :disabled="operation!=='add'" style="width: 200px" />
-        </el-form-item>
-        <el-form-item label="缁勭粐鍚嶇О" prop="OrganName">
-          <el-input v-model="dialogForm.OrganName" style="width: 200px" />
-        </el-form-item>
-        <el-form-item label="鎵�灞炵粍缁�" prop="storgcode">
-          <el-cascader
-            ref="cascader"
-            v-model="dialogForm.storgcode"
-            :options="cascaderOptions"
-            filterable
-            :props="defaultProps"
-            :show-all-levels="false"
-            @change="cascaderChange"
-          />
-        </el-form-item>
-        <el-form-item required label="缁勭粐鐘舵��">
-          <el-radio-group v-model="dialogForm.status">
-            <el-radio label="Y">姝e父</el-radio>
-            <el-radio label="N">鍋滅敤</el-radio>
-          </el-radio-group>
-        </el-form-item>
-      </el-form>
-      <span slot="footer" class="dialog-footer">
-        <div class="footerButton">
-          <el-button v-waves @click="dialogVisibleCancel">鍙� 娑�</el-button>
-          <el-button
-            v-waves
-            type="primary"
-            :loading="$store.state.app.buttonIsDisabled"
-            :disabled="$store.state.app.buttonIsDisabled"
-            @click="dialogVisibleConfirm"
-          >纭� 瀹�</el-button>
-        </div>
-      </span>
-    </el-dialog>
-
-  </div>
-</template>
-
-<script>
-import Pagination from '@/components/Pagination'
-import {
-  AddUpdateOrganization,
-  DeleteOrganization,
-  STorgData
-} from '@/api/basicSettings'
-import { validateCode } from '@/utils/global'
-import elDragDialog from '@/directive/el-drag-dialog'
-import waves from '@/directive/waves'
-import arrayToTree from 'array-to-tree'
-import { PrentOrganization } from '@/api/GeneralBasicData'
-
-export default {
-  name: 'OrganizationList',
-  components: {
-    Pagination
-  },
-  directives: { elDragDialog, waves },
-  data() {
-    return {
-      mainHeight: 0,
-      tableHeight: 0,
-      form: {
-        storg_code: '', // 缁勭粐鏋舵瀯缂栫爜
-        storg_name: '' // 缁勭粐鏋舵瀯鍚嶇О
-        // prop: 'lm_date', // 鎺掑簭瀛楁
-        // order: 'desc', // 鎺掑簭瀛楁
-        // page: 1, // 绗嚑椤�
-        // rows: 20 // 姣忛〉澶氬皯鏉�
-      },
-      total: 10,
-      tableData: [],
-      dialogVisible: false,
-      dialogForm: {
-        OrganCode: '', // 缁勭粐缂栫爜
-        OrganName: '', // 缁勭粐鍚嶇О
-        leve: 0, // 灞傜骇缂栫爜
-        storgcode: '', // 鐖剁骇缂栫爜
-        parent_id: '', // 鍘焢id
-        torg_seq: '', // 鎺掑簭
-        status: 'Y'// 鐘舵��
-      },
-      operation: '',
-      dialogFormRules: {
-        OrganCode: [
-          { required: true, validator: validateCode, trigger: ['blur', 'change'] }
-        ],
-        OrganName: [
-          { required: true, message: '璇疯緭鍏ョ粍缁囧悕绉�', trigger: ['blur', 'change'] }
-        ],
-        storgcode: [
-          { required: true, message: '璇烽�夋嫨鎵�灞炵粍缁�', trigger: ['blur', 'change'] }
-        ]
-      },
-      defaultProps: {
-        checkStrictly: true,
-        expandTrigger: 'hover',
-        value: 'torg_code',
-        label: 'torg_name'
-      },
-      Options: [],
-      cascaderOptions: []
-
-    }
-  },
-  activated() {
  window.addEventListener('resize', this.getHeight)
  this.getHeight()
},
created() {
-    this.getSTorgData()
-  },
-  mounted() {
-    window.addEventListener('resize', this.getHeight)
-    this.getHeight()
-  },
-  methods: {
-    // 缁勭粐鏋舵瀯澶у垪琛ㄦ煡璇�
-    async getSTorgData() {
-      const res = await STorgData(this.form)
-      this.tableData = arrayToTree(res.data, {
-        parentProperty: 'parent_id',
-        customID: 'torg_code',
-        childrenProperty: 'children'
-      })
-      this.total = res.count
-    },
-    // 缁勭粐鏋舵瀯绾ц仈閫夋嫨鍣�
-    async getPrentOrganization() {
-      const { data: res } = await PrentOrganization()
-      this.Options = res
-      this.cascaderOptions = arrayToTree(res, {
-        parentProperty: 'parent_id',
-        customID: 'torg_code',
-        childrenProperty: 'children'
-      })
-    },
-    // 鎺掑簭鏀瑰彉鏃�
-    sortChange({ column, prop, order }) {
-      if (order === 'descending') {
-        order = 'desc'
-      } else if (order === 'ascending') {
-        order = 'asc'
-      } else {
-        order = 'desc'
-      }
-      this.form.order = order
-      this.form.prop = prop
-      this.getSTorgData()
-    },
-    // 閲嶇疆
-    reset() {
-      this.form.storg_code = ''
-      this.form.storg_name = ''
-      this.getSTorgData()
-    },
-    // 鏂板鎸夐挳
-    add(operation) {
-      this.operation = operation
-      this.dialogVisible = true
-      this.dialogForm.OperType = 'Add'
-      this.getPrentOrganization()
-    },
-    // 淇敼鎸夐挳
-    async edit(operation, row) {
-      this.operation = operation
-      this.dialogVisible = true
-      this.dialogForm.OperType = 'Update'
-      await this.getPrentOrganization()
-      this.cascaderOptions = this.filterChildren(this.cascaderOptions, row.torg_code)
-      this.$nextTick(() => {
-        this.dialogForm.OrganCode = row.torg_code
-        this.dialogForm.OrganName = row.torg_name
-        this.dialogForm.leve = parseFloat(row.leve)
-        this.dialogForm.torg_seq = row.torg_seq
-        this.dialogForm.status = row.status
-        this.dialogForm.storgcode = this.findParent([], row.parent_id, this.cascaderOptions).reverse()
-        this.dialogForm.parent_id = row.parent_id
-      })
-    },
-    filterChildren(treeData, code) {
-      treeData.forEach(item => {
-        if (code.split(',').includes(item.torg_code)) {
-          item.disabled = true
-          if (item.children && item.children.length > 0) {
-            this.filterChildren(item.children, item.children.map(it => it.torg_code).join(','))
-          }
-        } else {
-          if (item.children && item.children.length > 0) {
-            this.filterChildren(item.children, code)
-          }
-        }
-      })
-      return treeData
-    },
-    // parents:鐢ㄤ簬杩斿洖鐨勬暟缁勶紝childNode:瑕佹煡璇㈢殑鑺傜偣锛宼reeData锛歫son鏍戝舰鏁版嵁
-    findParent(parents, childNode, treeData) {
-      // console.log(parents, childNode, treeData, 2)
-      for (let i = 0; i < treeData.length; i++) {
-        // 鐖惰妭鐐规煡璇㈡潯浠�
-        if (treeData[i].torg_code === childNode) {
-          // 濡傛灉鎵惧埌缁撴灉,淇濆瓨褰撳墠鑺傜偣
-          parents.push(treeData[i].torg_code)
-          // 鐢ㄥ綋鍓嶈妭鐐瑰啀鍘诲師鏁版嵁鏌ユ壘褰撳墠鑺傜偣鐨勭埗鑺傜偣
-          this.findParent(parents, treeData[i].parent_id, this.cascaderOptions)
-          break
-        } else {
-          if (treeData[i].children instanceof Array) {
-            //	娌℃壘鍒帮紝閬嶅巻璇ヨ妭鐐圭殑瀛愯妭鐐�
-            this.findParent(parents, childNode, treeData[i].children)
-          }
-        }
-      }
-      return parents
-    },
-    // 鍒犻櫎鎸夐挳
-    async del(row) {
-      this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
-        confirmButtonText: '纭畾',
-        cancelButtonText: '鍙栨秷',
-        type: 'warning'
-      }).then(() => {
-        DeleteOrganization({ orgcode: row.torg_code }).then(res => {
-          if (res.code === '200') {
-            this.$notify.success('鍒犻櫎鎴愬姛!')
-            if (this.form.page > 1 && this.tableData.length === 1) {
-              this.form.page--
-            }
-            this.getSTorgData()
-          }
-        })
-      }).catch(() => {
-        this.$notify.info('宸插彇娑堝垹闄�')
-      })
-    },
-    // 瀵硅瘽妗嗗叧闂簨浠�
-    handleClose() {
-      this.dialogForm.OrganCode = ''
-      this.dialogForm.OrganName = ''
-      this.dialogForm.storgcode = ''
-      this.dialogForm.parent_id = ''
-      this.dialogForm.status = 'Y'
-      this.dialogForm.leve = 0
-      this.$refs.cascader.checkedValue = ''
-      this.$refs.dialogForm.clearValidate()
-    },
-    cascaderChange(val) {
-      const temp = this.Options.find(i => i.torg_code === val[val.length - 1])
-      this.dialogForm.storgcode = val
-      this.dialogForm.leve = parseFloat(temp.leve) + 1
-      this.dialogForm.torg_seq = this.Options.filter(i => i.parent_id === val[val.length - 1]).length + 1
-    },
-    // 瀵硅瘽妗嗗彇娑�
-    dialogVisibleCancel() {
-      this.dialogVisible = false
-    },
-    // 瀵硅瘽妗嗙‘璁�
-    dialogVisibleConfirm() {
-      this.$refs.dialogForm.validate(valid => {
-        if (valid) {
-          this.$store.state.app.buttonIsDisabled = true
-          this.dialogForm.storgcode = this.dialogForm.storgcode[this.dialogForm.storgcode.length - 1]
-          AddUpdateOrganization(this.dialogForm).then(res => {
-            if (res.code === '200') {
-              this.$notify.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
-              this.dialogVisible = false
-              this.$store.state.app.buttonIsDisabled = false
-              this.getSTorgData()
-            } else {
-              this.$notify.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
-              this.$store.state.app.buttonIsDisabled = false
-            }
-          })
-        }
-      })
-    },
-    // 鑾峰彇椤甸潰楂樺害
-    getHeight() {
-      this.$nextTick(() => {
-        this.mainHeight = window.innerHeight - 85
-        this.tableHeight = this.mainHeight - 137
-        this.$refs.tableDataRef.doLayout()
-      })
-    }
-  }
-}
-</script>
+<template>
+  <div>
+    <div class="body" :style="{height:mainHeight+'px'}">
+      <div class="bodyTopButtonGroup" style="justify-content: space-between">
+        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
+      </div>
+
+      <div class="bodyTopFormGroup">
+        <el-form
+          ref="form"
+          :model="form"
+          label-width="100px"
+          inline
+          style="display: flex;"
+        >
+          <div class="elForm">
+            <el-form-item label="缁勭粐缂栫爜" style=" display: flex;">
+              <el-input v-model="form.storg_code" placeholder="璇疯緭鍏�" style="width: 200px" />
+            </el-form-item>
+            <el-form-item label="缁勭粐鍚嶇О" style=" display: flex;">
+              <el-input v-model="form.storg_name" placeholder="璇疯緭鍏�" style="width: 200px" />
+            </el-form-item>
+          </div>
+          <div
+            class="bodySearchReset"
+            :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
+          >
+            <el-button v-waves type="primary" icon="el-icon-search" @click="getSTorgData">鏌ヨ</el-button>
+            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
+          </div>
+        </el-form>
+        <div
+          class="bodyTopFormExpand"
+          style="height:5px"
+        >
+          <!--          <svg-icon-->
+          <!--            v-show="mouseHoverType==='mouseout'"-->
+          <!--            style="cursor: pointer"-->
+          <!--            :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"-->
+          <!--            @mouseenter="mouseHoverType=$event.type"-->
+          <!--          />-->
+          <!--          <svg-icon-->
+          <!--            v-show="mouseHoverType==='mouseenter'"-->
+          <!--            style="cursor: pointer"-->
+          <!--            :icon-class="!isExpandForm?'doubleDown':'doubleUp'"-->
+          <!--            @click="isExpandForm=!isExpandForm"-->
+          <!--            @mouseout="mouseHoverType=$event.type"-->
+          <!--          />-->
+        </div>
+      </div>
+
+      <div class="elTableDiv">
+        <el-table
+          ref="tableDataRef"
+          class="tableFixed"
+          :data="tableData"
+          :height="tableHeight+'px'"
+          border
+          row-class-name="custom-row"
+          :style="{width: 100+'%',height:tableHeight+'px',}"
+          highlight-current-row
+          row-key="torg_code"
+          default-expand-all
+          :header-cell-style="this.$headerCellStyle"
+          :cell-style="this.$cellStyle"
+          @sort-change="sortChange"
+        >
+          <!--          <el-table-column-->
+          <!--            prop="rowNum"-->
+          <!--            width="120"-->
+          <!--            fixed-->
+          <!--            label="搴忓彿"-->
+          <!--          />-->
+          <el-table-column
+            prop="torg_code"
+            label="缁勭粐缂栫爜"
+            sortable="custom"
+          />
+          <el-table-column
+            prop="torg_name"
+            label="缁勭粐鍚嶇О"
+            sortable="custom"
+          />
+          <el-table-column
+            prop="status"
+            label="鐘舵��"
+            sortable="custom"
+          >
+            <template slot-scope="{row}">
+              <el-tag v-if="row.status==='Y'" size="small" type="success">姝e父</el-tag>
+              <el-tag v-if="row.status==='N'" size="small" type="danger">鍋滅敤</el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="username"
+            label="鍒涘缓浜哄憳"
+            sortable="custom"
+          />
+          <el-table-column
+            prop="lm_date"
+            label="鍒涘缓鏃堕棿"
+            width="160"
+            sortable="custom"
+          />
+          <el-table-column
+            label="鎿嶄綔"
+            width="120"
+            fixed="right"
+          >
+            <template slot-scope="{row}">
+              <div class="operationClass">
+                <el-tooltip class="item" effect="dark" content="缂栬緫" placement="top">
+                  <i
+                    v-if="row.leve!==0"
+                    class="el-icon-edit-outline"
+                    :style="{color:$store.state.settings.theme}"
+                    @click="edit('edit',row)"
+                  />
+                </el-tooltip>
+                <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
+                  <i
+                    v-if="row.leve!==0"
+                    class="el-icon-delete"
+                    :style="{color:$store.state.settings.theme}"
+                    @click="del(row)"
+                  />
+                </el-tooltip>
+              </div>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+      <!--鍒嗛〉-->
+      <!--      <pagination-->
+      <!--        :total="total"-->
+      <!--        :page.sync="form.page"-->
+      <!--        :limit.sync="form.rows"-->
+      <!--        align="right"-->
+      <!--        layout="total,prev, pager, next,sizes,jumper"-->
+      <!--        popper-class="select_bottom"-->
+      <!--        @pagination="getSTorgData"-->
+      <!--      />-->
+    </div>
+
+    <el-dialog
+      v-el-drag-dialog
+      :title="operation==='add'?'鏂板':'缂栬緫'"
+      :visible.sync="dialogVisible"
+      width="800px"
+      :close-on-click-modal="false"
+      top="15vh"
+      @closed="handleClose"
+      @close="handleClose"
+    >
+      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
+        <el-form-item label="缁勭粐缂栫爜" prop="OrganCode">
+          <el-input v-model="dialogForm.OrganCode" :disabled="operation!=='add'" style="width: 200px" />
+        </el-form-item>
+        <el-form-item label="缁勭粐鍚嶇О" prop="OrganName">
+          <el-input v-model="dialogForm.OrganName" style="width: 200px" />
+        </el-form-item>
+        <el-form-item label="鎵�灞炵粍缁�" prop="storgcode">
+          <el-cascader
+            ref="cascader"
+            v-model="dialogForm.storgcode"
+            :options="cascaderOptions"
+            filterable
+            :props="defaultProps"
+            :show-all-levels="false"
+            @change="cascaderChange"
+          />
+        </el-form-item>
+        <el-form-item required label="缁勭粐鐘舵��">
+          <el-radio-group v-model="dialogForm.status">
+            <el-radio label="Y">姝e父</el-radio>
+            <el-radio label="N">鍋滅敤</el-radio>
+          </el-radio-group>
+        </el-form-item>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <div class="footerButton">
+          <el-button v-waves @click="dialogVisibleCancel">鍙� 娑�</el-button>
+          <el-button
+            v-waves
+            type="primary"
+            :loading="$store.state.app.buttonIsDisabled"
+            :disabled="$store.state.app.buttonIsDisabled"
+            @click="dialogVisibleConfirm"
+          >纭� 瀹�</el-button>
+        </div>
+      </span>
+    </el-dialog>
+
+  </div>
+</template>
+
+<script>
+import Pagination from '@/components/Pagination'
+import {
+  AddUpdateOrganization,
+  DeleteOrganization,
+  STorgData
+} from '@/api/basicSettings'
+import { validateCode } from '@/utils/global'
+import elDragDialog from '@/directive/el-drag-dialog'
+import waves from '@/directive/waves'
+import arrayToTree from 'array-to-tree'
+import { PrentOrganization } from '@/api/GeneralBasicData'
+
+export default {
+  name: 'OrganizationList',
+  components: {
+    Pagination
+  },
+  directives: { elDragDialog, waves },
+  data() {
+    return {
+      mainHeight: 0,
+      tableHeight: 0,
+      form: {
+        storg_code: '', // 缁勭粐鏋舵瀯缂栫爜
+        storg_name: '' // 缁勭粐鏋舵瀯鍚嶇О
+        // prop: 'lm_date', // 鎺掑簭瀛楁
+        // order: 'desc', // 鎺掑簭瀛楁
+        // page: 1, // 绗嚑椤�
+        // rows: 20 // 姣忛〉澶氬皯鏉�
+      },
+      total: 10,
+      tableData: [],
+      dialogVisible: false,
+      dialogForm: {
+        OrganCode: '', // 缁勭粐缂栫爜
+        OrganName: '', // 缁勭粐鍚嶇О
+        leve: 0, // 灞傜骇缂栫爜
+        storgcode: '', // 鐖剁骇缂栫爜
+        parent_id: '', // 鍘焢id
+        torg_seq: '', // 鎺掑簭
+        status: 'Y'// 鐘舵��
+      },
+      operation: '',
+      dialogFormRules: {
+        OrganCode: [
+          { required: true, validator: validateCode, trigger: ['blur', 'change'] }
+        ],
+        OrganName: [
+          { required: true, message: '璇疯緭鍏ョ粍缁囧悕绉�', trigger: ['blur', 'change'] }
+        ],
+        storgcode: [
+          { required: true, message: '璇烽�夋嫨鎵�灞炵粍缁�', trigger: ['blur', 'change'] }
+        ]
+      },
+      defaultProps: {
+        checkStrictly: true,
+        expandTrigger: 'hover',
+        value: 'torg_code',
+        label: 'torg_name'
+      },
+      Options: [],
+      cascaderOptions: []
+
+    }
+  },
+  activated() {
+    window.addEventListener('resize', this.getHeight)
+    this.getHeight()
+    this.getSTorgData()
+  },
+  created() {
+    this.getSTorgData()
+  },
+  mounted() {
+    window.addEventListener('resize', this.getHeight)
+    this.getHeight()
+  },
+  methods: {
+    // 缁勭粐鏋舵瀯澶у垪琛ㄦ煡璇�
+    async getSTorgData() {
+      const res = await STorgData(this.form)
+      this.tableData = arrayToTree(res.data, {
+        parentProperty: 'parent_id',
+        customID: 'torg_code',
+        childrenProperty: 'children'
+      })
+      this.total = res.count
+    },
+    // 缁勭粐鏋舵瀯绾ц仈閫夋嫨鍣�
+    async getPrentOrganization() {
+      const { data: res } = await PrentOrganization()
+      this.Options = res
+      this.cascaderOptions = arrayToTree(res, {
+        parentProperty: 'parent_id',
+        customID: 'torg_code',
+        childrenProperty: 'children'
+      })
+    },
+    // 鎺掑簭鏀瑰彉鏃�
+    sortChange({ column, prop, order }) {
+      if (order === 'descending') {
+        order = 'desc'
+      } else if (order === 'ascending') {
+        order = 'asc'
+      } else {
+        order = 'desc'
+      }
+      this.form.order = order
+      this.form.prop = prop
+      this.getSTorgData()
+    },
+    // 閲嶇疆
+    reset() {
+      this.form.storg_code = ''
+      this.form.storg_name = ''
+      this.getSTorgData()
+    },
+    // 鏂板鎸夐挳
+    add(operation) {
+      this.operation = operation
+      this.dialogVisible = true
+      this.dialogForm.OperType = 'Add'
+      this.getPrentOrganization()
+    },
+    // 淇敼鎸夐挳
+    async edit(operation, row) {
+      this.operation = operation
+      this.dialogVisible = true
+      this.dialogForm.OperType = 'Update'
+      await this.getPrentOrganization()
+      this.cascaderOptions = this.filterChildren(this.cascaderOptions, row.torg_code)
+      this.$nextTick(() => {
+        this.dialogForm.OrganCode = row.torg_code
+        this.dialogForm.OrganName = row.torg_name
+        this.dialogForm.leve = parseFloat(row.leve)
+        this.dialogForm.torg_seq = row.torg_seq
+        this.dialogForm.status = row.status
+        this.dialogForm.storgcode = this.findParent([], row.parent_id, this.cascaderOptions).reverse()
+        this.dialogForm.parent_id = row.parent_id
+      })
+    },
+    filterChildren(treeData, code) {
+      treeData.forEach(item => {
+        if (code.split(',').includes(item.torg_code)) {
+          item.disabled = true
+          if (item.children && item.children.length > 0) {
+            this.filterChildren(item.children, item.children.map(it => it.torg_code).join(','))
+          }
+        } else {
+          if (item.children && item.children.length > 0) {
+            this.filterChildren(item.children, code)
+          }
+        }
+      })
+      return treeData
+    },
+    // parents:鐢ㄤ簬杩斿洖鐨勬暟缁勶紝childNode:瑕佹煡璇㈢殑鑺傜偣锛宼reeData锛歫son鏍戝舰鏁版嵁
+    findParent(parents, childNode, treeData) {
+      // console.log(parents, childNode, treeData, 2)
+      for (let i = 0; i < treeData.length; i++) {
+        // 鐖惰妭鐐规煡璇㈡潯浠�
+        if (treeData[i].torg_code === childNode) {
+          // 濡傛灉鎵惧埌缁撴灉,淇濆瓨褰撳墠鑺傜偣
+          parents.push(treeData[i].torg_code)
+          // 鐢ㄥ綋鍓嶈妭鐐瑰啀鍘诲師鏁版嵁鏌ユ壘褰撳墠鑺傜偣鐨勭埗鑺傜偣
+          this.findParent(parents, treeData[i].parent_id, this.cascaderOptions)
+          break
+        } else {
+          if (treeData[i].children instanceof Array) {
+            //	娌℃壘鍒帮紝閬嶅巻璇ヨ妭鐐圭殑瀛愯妭鐐�
+            this.findParent(parents, childNode, treeData[i].children)
+          }
+        }
+      }
+      return parents
+    },
+    // 鍒犻櫎鎸夐挳
+    async del(row) {
+      this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
+        confirmButtonText: '纭畾',
+        cancelButtonText: '鍙栨秷',
+        type: 'warning'
+      }).then(() => {
+        DeleteOrganization({ orgcode: row.torg_code }).then(res => {
+          if (res.code === '200') {
+            this.$notify.success('鍒犻櫎鎴愬姛!')
+            if (this.form.page > 1 && this.tableData.length === 1) {
+              this.form.page--
+            }
+            this.getSTorgData()
+          }
+        })
+      }).catch(() => {
+        this.$notify.info('宸插彇娑堝垹闄�')
+      })
+    },
+    // 瀵硅瘽妗嗗叧闂簨浠�
+    handleClose() {
+      this.dialogForm.OrganCode = ''
+      this.dialogForm.OrganName = ''
+      this.dialogForm.storgcode = ''
+      this.dialogForm.parent_id = ''
+      this.dialogForm.status = 'Y'
+      this.dialogForm.leve = 0
+      this.$refs.cascader.checkedValue = ''
+      this.$refs.dialogForm.clearValidate()
+    },
+    cascaderChange(val) {
+      const temp = this.Options.find(i => i.torg_code === val[val.length - 1])
+      this.dialogForm.storgcode = val
+      this.dialogForm.leve = parseFloat(temp.leve) + 1
+      this.dialogForm.torg_seq = this.Options.filter(i => i.parent_id === val[val.length - 1]).length + 1
+    },
+    // 瀵硅瘽妗嗗彇娑�
+    dialogVisibleCancel() {
+      this.dialogVisible = false
+    },
+    // 瀵硅瘽妗嗙‘璁�
+    dialogVisibleConfirm() {
+      this.$refs.dialogForm.validate(valid => {
+        if (valid) {
+          this.$store.state.app.buttonIsDisabled = true
+          this.dialogForm.storgcode = this.dialogForm.storgcode[this.dialogForm.storgcode.length - 1]
+          AddUpdateOrganization(this.dialogForm).then(res => {
+            if (res.code === '200') {
+              this.$notify.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
+              this.dialogVisible = false
+              this.$store.state.app.buttonIsDisabled = false
+              this.getSTorgData()
+            } else {
+              this.$notify.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
+              this.$store.state.app.buttonIsDisabled = false
+            }
+          })
+        }
+      })
+    },
+    // 鑾峰彇椤甸潰楂樺害
+    getHeight() {
+      this.$nextTick(() => {
+        this.mainHeight = window.innerHeight - 85
+        this.tableHeight = this.mainHeight - 137
+        this.$refs.tableDataRef.doLayout()
+      })
+    }
+  }
+}
+</script>

--
Gitblit v1.9.3