<!-- 设备管理 -->
<template>
  <TableView class="product"
             @body-height-change="bodyHeightChange">
    <template slot="header">
      <BaseHeaderLayout>
        <template slot="left">
          <!-- 上传按钮 -->
          <span v-if="permissionIf('cloudDisk.dataManager.manage')">
            <ws-button v-if="!treeNode.name"
                       class="buttonClass"
                       type="primary"
                       @click="uploadError">{{ $t('system.fileManagement.button.upload') }}</ws-button>
            <ws-upload v-else
                       oss-key="dataManagement"
                       table-name="common_appendix"
                       :comp-id="compId"
                       :remark-word="word"
                       :appendix-ids="appendixIds"
                       @onChange="uploadSuccess"
                       @uploadSuccess="uploadSuccessInfo"
                       ref="upload"
                       style="display: inline-flex;padding:0; marginRight:10px">
            </ws-upload>
          </span>
          <!-- 批量下载按钮 -->
          <ws-button class="buttonClass"
                     :disabled="disabled"
                     v-if="permissionIf('cloudDisk.dataManager.download')"
                     @click="batchDown('')">{{ $t('button.download') }}</ws-button>
          <!-- 删除按钮 -->
          <ws-button class="buttonClass"
                     :disabled="disabled"
                     style="margin-left: 0 !important;"
                     v-if="permissionIf('cloudDisk.dataManager.manage')"
                     @click="batchDelete">{{ $t('button.delete') }}</ws-button>
        </template>
        <template slot="right">
          <ws-dropdown trigger="click"
                       class="dropdown"
                       style="margin-right:10px;"
                       @command="filterFileTypeList">
            <span class="el-dropdown-link">
              {{ filterFileType||getLanguage }}
              <i class="iconfont iconxiajiantou"
                 style="font-size:12px"></i>
            </span>
            <ws-dropdown-menu slot="dropdown"
                              style="max-width:200px;overflow-x: auto">
              <ws-dropdown-item v-for="(item,index) in fileTypeList"
                                :key="index"
                                :command="item"
                                style="word-break: break-all;white-space: nowrap;">
                {{ $t(item) }}
              </ws-dropdown-item>
            </ws-dropdown-menu>
          </ws-dropdown>
          <!-- 过滤 -->
          <!-- <ws-button type="text"
                     @click="dialogFormVisible = true">
            <i class="iconfont iconfilter" />
            <span>{{ $t('zs.common.sizer') }}</span>
          </ws-button>
          <span class="filter-total">{{ $t('zs.common.thereAre')
              }}{{ tableData.total ? tableData.total : 0
              }}{{ $t('cg.queryresults') }}</span> -->
          <BaseHeaderFilter :total="tableData.total"
                            @click="dialogFormVisible = true" />
          <BaseInputSearch v-model="page.fileName"
                           :placeholder="$t('dataManage.screeningTips')"
                           @search="handleFilter('title')" />
        </template>
      </BaseHeaderLayout>
    </template>
    <template slot="body">
      <div class="data-manage">
        <ws-row style="height:calc(100% - 40px)">
          <ws-col :span="5">
            <div class="ShipEquipmentTreeBody">
              <div class="ShipEquipmentTreeTitle">
                <span>{{ $t('dataManage.dataFolder') }}</span>
                <yh-operaction class="fr"
                               :lable="treeTitleLable"
                               @skip="skipTreeTitle" />
              </div>
              <div style="width: 100%;height: calc(100vh - 161px);overflow: auto">
                <div class="treeClass">
                  <ws-tree class="filter-tree"
                           v-if="TreeData && TreeData.length > 0"
                           :data="TreeData"
                           :props="defaultProps"
                           :highlight-current="true"
                           node-key="id"
                           :default-expanded-keys="defaultExpandedKeys"
                           @node-click="clickNode">
                    <div class="custom-tree-node"
                         slot-scope="{ node, data }">
                      <span>
                        <el-tooltip class="item"
                                    effect="dark"
                                    :content="node.label"
                                    :disabled="node.label.length<10"
                                    placement="top">
                          <span v-if="!data.addFlag && !data.editFlag"
                                class="tree-label">{{ node.label }}</span>
                        </el-tooltip>
                        <ws-input v-if="data.addFlag"
                                  v-model="data.name"
                                  size="small"
                                  maxlength="100"
                                  @keyup.enter.native="$event.target.blur"
                                  @blur="saveFloder(data)" />
                        <ws-input v-if="data.editFlag"
                                  v-model="data.name"
                                  size="small"
                                  maxlength="100"
                                  :clearable="false"
                                  @keyup.enter.native="$event.target.blur"
                                  @blur="renameFloder(data)" />
                      </span>
                      <div @click.stop="clickOperation">
                        <operaction-new v-if="!data.addFlag && !data.editFlag"
                                        class="fr"
                                        :lable="treeLable"
                                        :data="data"
                                        :node="node"
                                        @skip="skipTree" />
                      </div>
                      <!-- <i class="iconfont iconsavey"
                         v-if="data.addFlag"
                         @click="saveFloder(data)"
                         style="margin: 0 5px;font-size: 14px;margin-top: 4px;" />

                      <i class="iconfont iconsavey"
                         v-if="data.editFlag"
                         @click="renameFloder(data)"
                         style="margin: 0 5px;font-size: 14px;margin-top: 4px;" /> -->

                      <!-- <span v-if="data.addFlag"
                            @click="cancelFloder(node, data)"><i class="el-icon-close"
                           style="font-size: 15px;margin-top: 5px;"></i></span>
                      <span v-if="data.editFlag"
                            @click="cancelFloder(node, data)"><i class="el-icon-close"
                           style="font-size: 15px;margin-top: 5px;"></i></span> -->
                    </div>
                  </ws-tree>
                </div>
              </div>
            </div>
          </ws-col>
          <ws-col :span="19">
            <div class="main-list"
                 style="padding-right: 0px">
              <ws-normal-table :data="tableData.records"
                               @cell-click="showDialog"
                               @selection-change="handleSelectionChange"
                               @sort-change="sortChange"
                               highlight-current-row
                               style="width: 100%;"
                               :height="tableViewBodyHeight - 67">
                <ws-table-column type="selection"
                                 width="30"></ws-table-column>
                <ws-table-column type="index"
                                 width="50"
                                 align="center"
                                 :label="$t('common.num')">
                  <template slot-scope="scope">{{ scope.$index + 1 }}</template>
                </ws-table-column>
                <ws-table-column width="80"
                                 :label="$t('dataManage.table.thumbnail')">
                  <template slot-scope="scope">
                    <winsea-picture-view v-if="isImage(scope.row.fileInfoType ? scope.row.fileInfoType.replace('文件', '').replace('.', ''): '')"
                                         class="mypicture"
                                         :pic-small-list="$store.getters.baseInfo.fileUrl + scope.row.filePath"
                                         :pic-list="$store.getters.baseInfo.fileUrl + scope.row.filePath"
                                         :hover-view="true"
                                         :width="40"
                                         :height="40" />
                    <i v-else
                       class="iconfont"
                       :class="getIconClass(scope.row.fileInfoType ? scope.row.fileInfoType.replace('文件', '').replace('.', ''): '')"></i>
                  </template>
                </ws-table-column>
                <ws-table-column prop="fileName"
                                 sortable="custom"
                                 min-width="200"
                                 show-overflow-tooltip
                                 :label="$t('dataManage.table.fileName')">
                  <template slot-scope="scope">
                    <span v-if="!scope.row.renameFlag"
                          @click="preview(scope.row)">{{
                        scope.row.fileName +
                          (scope.row.fileInfoType
                            ? scope.row.fileInfoType.replace('文件', '')
                            : '')
                      }}</span>
                    <span v-else
                          style="display: flex">
                      <ws-input v-model="scope.row.fileNameClone" />
                      <i class="iconfont iconsavey"
                         @click="saveName(scope.row)"
                         style="margin: 0 5px;font-size: 14px;margin-top: 4px;" />
                      <span @click="scope.row.renameFlag = false"><i class="el-icon-close"
                           style="font-size: 15px;margin-top: 7px;"></i></span>
                    </span>
                  </template>
                </ws-table-column>
                <ws-table-column prop="createDate"
                                 sortable="custom"
                                 width="180"
                                 :label="$t('dataManage.uploadTime')">
                  <template slot-scope="scope">{{
                    scope.row.createDate
                  }}</template>
                </ws-table-column>
                <ws-table-column prop="fileInfoType"
                                 width="120"
                                 :label="$t('dataManage.table.type')">
                  <template slot-scope="scope">{{
                    scope.row.fileInfoType
                      ? scope.row.fileInfoType
                          .replace('文件', '')
                          .replace('.', '')
                      : ''
                  }}</template>
                </ws-table-column>
                <ws-table-column prop="fileSize"
                                 sortable="custom"
                                 width="100"
                                 align="right"
                                 :label="$t('dataManage.table.size')">
                  <template slot-scope="scope">{{
                    scope.row.fileSize
                  }}</template>
                </ws-table-column>
                <ws-table-column prop="statusFlag"
                                 :label="$t('common.operate')"
                                 align="center"
                                 width="80">
                  <template slot-scope="scope">
                    <operaction-new :lable="lable"
                                    :status-flag="scope.row.statusFlag"
                                    :data="scope"
                                    @skip="skipPage" />
                  </template>
                </ws-table-column>
              </ws-normal-table>
              <pagination v-if="tableData.total > 0"
                          :total="tableData.total"
                          :page.sync="page.currentPage"
                          :limit.sync="page.pageSize"
                          @pagination="getList" />
            </div>
          </ws-col>
        </ws-row>
        <!-- 过滤dialog -->
        <div class="nav-search">
          <div class="searchTwo">
            <ws-dialog :title="$t('button.filtration')"
                       :visible.sync="dialogFormVisible"
                       width="341px"
                       :modal="false"
                       style="top: -40px;"
                       class="dialog"
                       :close-on-click-modal="false">
              <ws-form ref="spclearsplistqueryForm"
                       :model="page"
                       label-width="80px"
                       label-position="left">
                <!-- 上传时间 -->
                <div class="selectTitle">
                  <span>{{ $t('dataManage.uploadTime') }}</span>
                </div>
                <!-- <ws-form-item :label=""> -->
                <ws-date-picker v-model="uploadDate"
                                :placeholder="$t('common.selected')"
                                type="daterange"
                                :range-separator="$t('common.to')"
                                :start-placeholder="$t('common.startDate')"
                                :end-placeholder="$t('common.endDate')"
                                value-format="yyyy-MM-dd"></ws-date-picker>
                <!-- </ws-form-item> -->
              </ws-form>
              <div slot="footer"
                   class="dialog-footer">
                <ws-button @click="clearfiltQuery">{{
                $t('button.reset')
              }}</ws-button>
                <ws-button type="primary"
                           @click="handleFilter">{{
                $t('button.filtration')
              }}</ws-button>
              </div>
            </ws-dialog>
          </div>
        </div>
        <!-- 移动文件 -->
        <WinseaContentModal v-model='dialogSortVisible'
                            :title="$t('dataManage.moveFile')">
          <ws-tree class="filter-tree"
                   v-if="TreeData && TreeData.length > 0"
                   :data="TreeData"
                   :props="defaultProps"
                   :highlight-current="true"
                   @node-click="clickFileNode" />
          <template slot="footer"
                    class="dialog-footer">
            <ws-button @click="dialogSortVisible = false">{{
              $t('button.cancel')
            }}</ws-button>
            <ws-button type="primary"
                       @click="moveFloder">{{
              $t('button.confirm')
            }}</ws-button>
          </template>
        </WinseaContentModal>
        <!-- </ws-dialog> -->
      </div>
    </template>
    <!-- pdf在线预览 -->

    <BaseDialog width="70%"
                :title="pdfFileName"
                :visible.sync="isShowPdf"
                :appendToBody="true">
      <pdf :loadUrl="pdfUrl"
           v-if="isShowPdf"></pdf>
    </BaseDialog>
  </TableView>
</template>
<script>
import { zipDown } from '../../utils/batchDown'
import Pagination from '@/components/Pagination'
import WsUpload from '@/components/WsUpload/index'
import yhOperaction from '@/components/WinseaCom/operaction.vue'
import operactionNew from '@/components/WinseaCom/operaction-new.vue'
import { getHp } from '@/utils/getHasPermission'
import { map, cloneDeep } from 'lodash'
import TableView from '@/layout/TableView'
import TableViewMix from '@/layout/mixin/TableViewMix'
import {
  findTreeList,
  findFileUnderFolder,
  removeAll,
  addInfo,
  findFileType,
  fileRename,
  changeInfo,
  addFile,
  moveFile,
  removeInfo
} from '@/model/dataManageMent'
import pdf from '@/components/pdf/pdf'
import { getFileList } from '@/model/upload'
import { EventBus } from 'base-core-lib'
export default {
  mixins: [TableViewMix],
  components: {
    Pagination,
    WsUpload,
    yhOperaction,
    operactionNew,
    TableView,
    pdf
  },
  data () {
    return {
      pdfFileName: '',//pdf
      isShowPdf: false,
      pdfUrl: '',
      filterFileType: '',
      defaultExpandedKeys: [],
      dialogSortVisible: false,
      treeNodeId: '',
      treeNode: {},
      // listLoading: false,
      compId: localStorage.getItem('ws-pf_compId'),
      word: false,
      //  附件
      appendixIds: '',
      historyAppendixIds: '',
      disabled: true,
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      tableData: {
        total: 0
      },
      fileTypeList: [],
      moveFolderObj: {},
      page: {
        folderId: '',
        fileName: '',
        fileInfoType: '',
        updateTimeStart: '',
        updateTimeEnd: '',
        orderColunm: '',
        order: '',
        currentPage: 1,
        pageSize: 10
      },
      uploadDate: [],
      selectedIds: '',
      selectedAppendixIds: '',
      // vesselList: [],
      activeName: '1',
      // 过滤显示设置Dialog
      dialogFormVisible: false,
      // 左侧树
      TreeData: [],
      parentId: '',
      uploadUrl: '', //config.getUploadPath('systemOperation', localStorage.getItem('ws-pf_compId'))
      filePath: ''
    }
  },
  created () {
    // this.vesselList = JSON.parse(localStorage.getItem('ws-pf_vessels'))
    this.getSystemFolderList()
    this.getFileTypeList()
  },
  computed: {
    getLanguage () {
      return this.$t('gg.allTypeName')
    },
    lable () {
      return [
        {
          lab: this.$t('button.download'),
          click: 'download',
          hp: getHp('cloudDisk.dataManager.download')
        },
        {
          lab: this.$t('button.delete'),
          click: 'delete',
          hp: getHp('cloudDisk.dataManager.manage')
        },
        {
          lab: this.$t('button.move'),
          click: 'move',
          hp: getHp('cloudDisk.dataManager.manage')
        },
        {
          lab: this.$t('button.rename'),
          click: 'rename',
          hp: getHp('cloudDisk.dataManager.manage')
        }
      ]
    },
    treeLable () {
      return [
        {
          lab: this.$t('button.newFolder'),
          click: 'newFolder',
          hp: getHp('cloudDisk.dataManager.manage')
        },
        {
          lab: this.$t('button.rename'),
          click: 'rename',
          hp: getHp('cloudDisk.dataManager.manage')
        },
        {
          lab: this.$t('button.delete'),
          click: 'delete',
          hp: getHp('cloudDisk.dataManager.manage')
        }
      ]
    },
    treeTitleLable () {
      return [
        {
          lab: this.$t('button.newFolder'),
          click: 'newFolder',
          hp: getHp('cloudDisk.dataManager.manage')
        }
      ]
    },
  },
  methods: {
    preview () { },
    showDialog (row) {
      if (row.fileInfoType === '.pdf文件') {
        getFileList({
          appendixIds: row.appendixId,
        }).toPromise().then(res => {
          let path = res[0] ? res[0].appendixPath : ''
          let filePath = this.$store.getters.baseInfo.fileUrl + '/' + path
          this.pdfUrl = filePath
          this.pdfFileName = row.fileName
          this.isShowPdf = true

        })
      }
    },
    // 文件类型数据
    async getFileTypeList () {
      await findFileType({ compId: localStorage.getItem('ws-pf_compId') }).toPromise().then(
        res => {
          this.fileTypeList = res
            .filter(item => (item != ''))
          this.fileTypeList.unshift('gg.allTypeName')
        }
      )
      this.getList()
    },
    //文件类型筛选
    filterFileTypeList (selFileType) {
      if (selFileType === 'gg.allTypeName') {
        this.filterFileType = ''
        this.page.fileInfoType = ''
      } else {
        this.filterFileType = this.$t(selFileType)
        this.page.fileInfoType = selFileType
      }
      this.getList()
    },
    isImage (type) {
      const imageType = ['png', 'jpg', 'jpeg', 'gif', 'PNG', 'JPG', 'JPEG', 'GIF']
      return imageType.includes(type)
    },
    getIconClass (type) {
      const iconClass = {
        docx: 'iconword',
        doc: 'iconword',
        zip: 'iconrary',
        xlsx: 'iconexcely',
        xls: 'iconexcely',
        ppt: 'iconppty',
        pptx: 'iconppty',
        pdf: 'iconpdf3',
        txt: 'icontxt1',
        rar: 'iconyasuo'
      }
      //     font-size: 35px;
      return iconClass[type] + ' otherClass otherClass__' + type || 'iconemly'
    },
    uploadError () {
      EventBus.$emit('error', this.$t('dataManage.message.message1'))
    },
    // 文件重命名
    async saveName (row) {
      const file = this.tableData.records.find(item => item.fileId === row.fileId)
      if (file.fileNameClone === file.fileName) {
        row.fileNameClone = row.fileNameClone.substr(0, 50)
      }
      if (row.fileNameClone && row.fileNameClone.length > 50) {
        EventBus.$emit('error', '文件名称不能超过50个字，请重新编辑')
      } else {
        // this.elLoading()
        // this.listLoading  = true
        const data = {
          fileId: row.fileId,
          fileName: row.fileNameClone
        }
        await fileRename(data).toPromise().then(res => {
          EventBus.$emit('success', this.$t('message.message1'))
          row.renameFlag = false
          this.getList()
          // this.elLoading('end')
        })
      }
    },
    async saveFloder (data) {
      if (data.name.length > 0) {
        await addInfo({ name: data.name, parentFolderId: this.parentId }).toPromise().then(
          res => {
            this.$set(data, 'id', res)
            this.$set(data, 'addFlag', false)
            EventBus.$emit('success', this.$t('message.message1'))
            this.page.folderId = res
            // this.getList()
            this.getSystemFolderList(this.parentId) // 陈小龙提1020979号bug说保存后不能影响其他展开的节点
          }
        )
      } else {
        this.cancelFloder()
        // EventBus.$emit('error', this.$t('workNotification.startPlaceholder'))
      }
    },
    // 重命名
    async renameFloder (data) {

      if (data.name.length > 0 && data.name !== data.oldName) {
        await changeInfo({
          name: data.name,
          folderId: data.folderId,
          parentFolderId: data.parentFolderId
        }).toPromise().then(res => {
          EventBus.$emit('success', this.$t('message.message1'))
          data.editFlag = false
          this.getSystemFolderList(data.parentFolderId)  // 陈小龙提1020979号bug说保存后不能影响其他展开的节点
        })
      } else {
        this.cancelFloder()
      }
    },
    cancelFloder (node, data) {
      this.getSystemFolderList()
    },
    // 新建文件夹
    skipTreeTitle () {
      this.TreeData.push({
        children: [],
        name: '',
        addFlag: true
      })
      this.parentId = ''
    },
    // 文件夹操作
    async skipTree (val) {
      const { msg, data, node } = val
      if (msg === 'newFolder') {
        data.children.push({
          children: [],
          name: '',
          addFlag: true
        })
        this.parentId = data.id
        this.defaultExpandedKeys = [data.id]
      } else if (msg === 'rename') {
        data.editFlag = true
        this.parentId = data.id
      } else if (msg === 'delete') {
        let message =
          data.children.length === 0
            ? this.$t('showMessage.delate')
            : this.$t('dataManage.message.message4')
        this.$confirm(message, this.$t('showMessage.hint'), {
          confirmButtonText: this.$t('button.confirm'),
          cancelButtonText: this.$t('button.cancel'),
          type: 'warning'
        })
          .then(() => {
            removeInfo({ folderId: data.id }).toPromise()
              .then(response => {
                const parent = node.parent
                const children = parent.data.children || parent.data
                const index = children.findIndex(d => d.id === data.id)
                children.splice(index, 1)
                EventBus.$emit('success', this.$t('showMessage.successfullyDelete'))
              })
              .catch(() => {
                EventBus.$emit('error', this.$t('showMessage.deleteFailed'))
              })
          })
          .catch(() => {
            EventBus.$emit('info', this.$t('showMessage.cancelledDelete'))
          })
      }
    },
    clickOperation () {
      // console.log('mmm')
    },
    async skipPage (val) {
      if (val.msg === 'delete') {
        this.$confirm(
          this.$t('dataManage.message.message3'),
          this.$t('showMessage.hint'),
          {
            confirmButtonText: this.$t('button.confirm'),
            cancelButtonText: this.$t('button.cancel'),
            type: 'warning'
          }
        )
          .then(() => {
            removeAll([{ fileId: val.data.row.fileId }]).toPromise()
              .then(response => {
                this.getList()
                EventBus.$emit('success', this.$t('showMessage.successfullyDelete'))
              })
              .catch(() => {
                EventBus.$emit('error', this.$t('showMessage.deleteFailed'))
              })
          })
          .catch(() => {
            EventBus.$emit('info', this.$t('showMessage.cancelledDelete'))
          })
      } else if (val.msg === 'move') {
        this.moveFolderObj.fileId = val.data.row.fileId
        this.dialogSortVisible = true
      } else if (val.msg === 'rename') {
        this.$set(this.tableData.records[val.data.$index], 'renameFlag', true)
      } else if (val.msg === 'download') {
        this.batchDown(val.data.row.appendixId)
        // getFileList({ appendixIds: val.data.row.appendixId}).then((res) => {
        //   window.open(res.data[0].appendixPath)
        // })
      }
    },
    // 批量下载
    batchDown (val) {
      zipDown({
        appendixIds: val.length !== 0 ? val : this.selectedAppendixIds,
        baseUrl: this.$store.getters.baseInfo.fileUrl
      })
    },
    // 文件夹一览查询
    async getSystemFolderList (defaultId = '') {
      // this.elLoading()
      // this.listLoading  = true
      await findTreeList({ compId: localStorage.getItem('ws-pf_compId') }).toPromise().then(
        response => {
          this.TreeData = response
          this.getTreeChildren(this.TreeData)
          this.treeNode = {}
          if (defaultId) {
            this.defaultExpandedKeys = [defaultId]
          }
          this.getList()
        }
      )
    },
    getTreeChildren (child) {
      for (var i in child) {
        this.$set(child[i], 'oldName', child[i].name)
        if (child[i].children) {
          this.getTreeChildren(child[i].children)
        }
      }
    },
    uploadSuccessInfo (item) {
      this.filePath = item.appendixPath
    },
    // 文件上传
    uploadSuccess () {
      this.$refs.upload
        .handleSaveBill()
        .then(async response => {
          await addFile({
            appendixIds: response.split(','),
            folderId: this.treeNodeId,
            compId: localStorage.getItem('ws-pf_compId'),
            filePath: this.filePath
          }).toPromise()
            .catch(res => {
              EventBus.$emit('error', (JSON.parse(res) || {}).message)
              this.$refs.upload.clearFiles()
            })
          this.getList()
          this.$refs.upload.clearFiles()
        })
        .catch(res => {
          EventBus.$emit('error', (JSON.parse(res) || {}).message)
          this.$refs.upload.clearFiles()
        })
    },
    // table多选
    handleSelectionChange (val) {
      this.disabled = !(val.length > 0)
      this.selectedIds = []
      for (let i of val) {
        this.selectedIds.push({
          fileId: i.fileId
        })
      }
      this.selectedAppendixIds = map(val, 'appendixId').join(',')
    },
    // sortChange 排序
    sortChange (val) {
      this.page.order = val.order
      this.page.orderColunm = val.prop
      this.getList()
    },
    async batchDelete () {
      this.$confirm(
        this.$t('dataManage.message.message2'),
        this.$t('showMessage.hint'),
        {
          confirmButtonText: this.$t('button.confirm'),
          cancelButtonText: this.$t('button.cancel'),
          type: 'warning'
        }
      )
        .then(() => {
          removeAll(this.selectedIds).toPromise().then(res => {
            EventBus.$emit('success', this.$t('showMessage.successfullyDelete'))
            this.page.currentPage = 1
            this.getList()
            EventBus.$emit('success', this.$t('showMessage.successfullyDelete'))
              .catch(() => {
                EventBus.$emit('error', this.$t('showMessage.deleteFailed'))
              })
          })
        })
        .catch(() => {
          EventBus.$emit('info', this.$t('showMessage.cancelledDelete'))
        })
    },
    // 点击树节点
    clickNode (obj, node) {
      if (obj.addFlag || obj.editFlag) {
        return
      }
      this.treeNodeId = obj.id
      this.treeNode = obj
      this.page.folderId = obj.id
      this.page.currentPage = 1
      this.getList()
    },
    // 移动
    clickFileNode (obj, node) {
      this.moveFolderObj.folderId = obj.folderId
    },
    // 移动文件-确定
    async moveFloder () {
      await moveFile(this.moveFolderObj).toPromise()
        .then(res => {
          this.getFileTypeList()
          this.getList()
          this.dialogSortVisible = false
          EventBus.$emit('success', this.$t('message.message1'))
        })
        .catch(res => {
          EventBus.$emit('error', res.message)
        })
    },
    // 模板文件列表
    async getList () {
      if (!this.listLoading) {
        // this.elLoading()
        // this.listLoading  = true
      }
      await findFileUnderFolder(this.page).toPromise().then(res => {
        let tableObj = res
        for (const i in res.records) {
          tableObj.records[i].renameFlag = false
          tableObj.records[i].fileNameClone = cloneDeep(
            res.records[i].fileName
          )
        }
        console.log(tableObj, 33339)
        this.tableData = tableObj
        // this.listLoading  = false
        // this.elLoading('end')
      })
    },

    resetSearch () {
      this.page.fileName = ''
      this.getList()
    },
    // 过滤
    handleFilter () {
      // 2020.05.25【资料管理】过滤条件，根据文档类型搜索，点击过滤按钮，弹出框不消失
      this.page.updateTimeStart = ''
      this.page.updateTimeEnd = ''

      if (this.uploadDate && this.uploadDate.length > 0) {
        this.page.updateTimeStart = this.uploadDate[0]
        this.page.updateTimeEnd = this.uploadDate[1]
      }

      this.getList()
      this.dialogFormVisible = false
    },
    // 过滤重置/过滤关闭X
    clearfiltQuery () {
      // this.page.fileInfoType = ''
      this.page.updateTimeStart = ''
      this.page.updateTimeEnd = ''
      this.page.updateTimeEnd = ''
      this.uploadDate = []
      this.dialogFormVisible = false
      this.getList()
    }
  }
}
</script>

<style lang="scss" scoped>
.otherClass {
  font-size: 34px;
  &__doc,
  &__docx {
    color: rgb(108, 203, 255);
  }
  &__zip {
    color: rgb(74, 141, 255);
  }
  // zip
  &__xlsx,
  &__xls {
    color: rgb(0, 192, 144);
  }
  &__ppt,
  &__pptx {
    color: rgb(255, 120, 97);
  }
  &__pdf {
    color: rgb(255, 72, 103);
  }
  &__txt {
    // color: rgb(108, 203, 255);
    font-size: 25px;
  }
  &__rar {
    color: rgb(226, 215, 66);
  }
}
.mypicture {
  ::v-deep ul {
    padding-inline-start: 0px;
    margin-block-start: 0px;
    margin-block-end: 0px;
  }
}
.content {
  float: right;
  line-height: 47px;
  width: 92%;
}
.data-manage {
  height: calc(100vh - 60px);
  .tree-label {
    margin-right: 10px;
  }
  .custom-tree-node {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    .el-input--small /deep/ .el-input__inner {
      height: 26px !important;
      line-height: 26px !important;
    }
    .tree-label {
      display: inline-block;
      white-space: nowrap;
      max-width: 160px;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
  .el-tree-small .el-tree-node__label {
    font-size: 14px;
  }
  .topBtn {
    margin-bottom: 5px;
    text-align: left;
  }
  .selectBtn {
    float: left;
    text-align: left;
  }
  .selectInput {
    float: right;
    width: 225px;
    margin-left: 15px;
  }
  .searchIcon {
    font-size: 32px;
    position: absolute;
    top: 0;
    right: 0;
  }
  .filter-total {
    font-size: 14px;
    float: right;
    margin-top: 10px;
    margin-left: 10px;
  }
  /deep/ .myDialogDiv .el-dialog {
    position: fixed;
    top: 0px;
    right: 15%;
    overflow: auto;
    margin: 0;
    width: 25em !important;
  }

  /deep/ .el-dialog .el-dialog__footer {
    height: 50px;
    line-height: 50px;
    padding: 0 20px 0 0;
  }
  /deep/ .el-table-column--selection .cell {
    padding-left: 10px;
    padding-right: 10px;
  }
  .el-row {
    .el-col:last-child {
      .el-form-item {
        border-bottom: 0px;
        border-right: 0px;
        .el-form-item__label {
          border-bottom: 0;
        }
      }
    }
  }
  .ShipEquipmentTreeBody {
    background-color: white;
    border: 1px #cccccc solid;
    width: 100%;
    height: calc(100vh - 120px);
    overflow: auto;
  }
  .ShipEquipmentTreeTitle {
    padding: 10px;
    background-color: white;
    border-bottom: 1px #cccccc solid;
    font-weight: bold;
    font-size: 16px;
  }
  .treeClass {
    padding: 10px;
    /*overflow-y: scroll;*/
    /*overflow-x: scroll;*/
    width: max-content;
    min-width: 100%;
  }
  /deep/ .el-upload-list--picture-card {
    display: none;
  }
}
.dropdown {
  line-height: 30px;
  float: right;
}

/deep/ .searchTwo .yhElDialog {
  right: 17vh;
  position: absolute;
  top: 19px !important;
  margin: 0;
}
.buttonClass {
  margin-right: 10px;
}
.product {
  /deep/ .el-upload-list__item {
    display: none;
  }
}
</style>
