entityManager.dataTemplate.vue.ftl 3.68 KB
<#assign baseUrl><#noparse>${</#noparse>${cfg.system}<#noparse>}</#noparse><#if package.ModuleName??>/${package.ModuleName}</#if>/${table.entityPath}/v1</#assign>
<template>
  <div class="data_view">
    <h3 style="padding-left: 20px; font-size: 14px" class="data_view__title">
      {{ templateInfo.name }}
    </h3>
    <div class="data-preview-wrap">
      ${cfg.dataTemplateHtml}
      <${table.entityName}-manager-edit ref="${table.entityName}ManagerEdit"></${table.entityName}-manager-edit>
    </div>
  </div>
</template>
<script>
import ${table.entityName}ManagerEdit from "./${table.entityName}ManagerEdit.vue";
import templatePreview from 'hotent-ui/src/mixins/templatePreview.js'
import api from "@/api/${table.entityName}.js"
export default {
  mixins: [templatePreview],
  components:{${table.entityName}ManagerEdit},
  data() {
    return {
      dialogVisible: false,
      rows: [],
      saveMethod: "POST",
      single: "true",
      templateInfo:${cfg.dataTemplateInfo}
    };
  },
  mounted() {
    this.$validator = this.$root.$validator;
  },
  methods: {
    showDialog(id) {
      this.$refs.${table.entityName}ManagerEdit.showDialog(id);
    },
    deleteByIds(ids) {
      if (!ids || ids.length === 0) {
        this.$message.warning('请至少选中一条数据!')
        return
      }
	  api.deleteByIds(ids.join(',')).then((resp) => {
	    let response = resp.data || resp
	    if (response.state) {
	      this.$message.success(response.message || '删除成功')
	      this.loadData()
	    }
	  })
    },
    loadData(param, cb) {
      api.loadData(param || {})
        .then(resp => {
          let response = resp.data || resp
          this.rows = response.rows
          this.total = response.total
          this.pagination = {
            page: response.page,
            pageSize: response.pageSize,
            total: response.total
          }
          this.$loading().close()
        })
        .finally(() => cb && cb())
    },
    getBpmTemplateByPagination(param, cb1, cb2) {
      this.loadData(param.pagination || {}, () => {
          cb1 && cb1()
          cb2 && cb2()
        })
    },
    initTree(treeField) {},
    getSubDataPagination(tab, name, refId, resolve, final) {},
    formGetSubEntsByFormKey() {},
    async scriptClick(btnAlias, afterScriptValue, parameter) {
      if(btnAlias =='add'){
        this.showDialog();
      }else if(btnAlias =='edit'){
        this.showDialog(parameter.id);
      } else if (btnAlias == 'del') {
        this.deleteByIds([parameter.pkField])
      }else if (btnAlias == 'deleted') {
      	let ids = []
      	const _selecData = this.$refs.multipleTemplateTable.selection
      	_selecData &&
        	_selecData.forEach((element) => {
          		let id = element[this.templateInfo.pkField || 'id'] || element.id
          		ids.push(id)
        	})
      	this.deleteByIds(ids)
      }
    }
  }
};
</script>
<style lang="scss" scoped>
  >>> th.todo-header-row {
    background-color: #fafafa;
    font-size: 13px;
  }

  >>> tr.todo-row {
    font-size: 13px;
  }

  .el-container {
    background-color: #fff;
  }

  .el-row {
    margin-bottom: 20px;
  }

  .el-header {
    border-bottom: 1.5px solid #ededed;
  }

  .i {
    margin-right: 4px;
  }

  .todo-subject {
    cursor: pointer;
  }

  >>> .el-dialog__body {
    padding: 15px 10px;
  }

  >>> .el-checkbox {
    margin-left: 15px;
  }

  >>> .el-radio {
    margin-left: 15px;
  }

  >>> .el-button {
    margin-left: 0px;
  }
  .loaded-fail__div {
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    color: #f56c6c;
  }
  .data-preview-wrap
    ::v-deep
    .dropdown-upload__btn
    > .el-button-group
    > button:first-child {
    margin: 0;
    padding: 0;
  }
</style>