123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525 |
- <template>
- <div>
- <basic-container>
- <avue-crud :option="option"
- :table-loading="loading"
- :data="data"
- ref="crud"
- v-model="form"
- :permission="permissionList"
- :before-open="beforeOpen"
- :before-close="beforeClose"
- @row-del="rowDel"
- @row-update="rowUpdate"
- @row-save="rowSave"
- @search-change="searchChange"
- @search-reset="searchReset"
- @selection-change="selectionChange"
- @current-change="currentChange"
- @size-change="sizeChange"
- @refresh-change="refreshChange"
- @on-load="onLoad"
- @tree-load="treeLoad">
- <template slot="menuLeft">
- <el-button type="danger"
- size="small"
- icon="el-icon-delete"
- v-if="permission.dept_delete"
- plain
- @click="handleDelete">删 除
- </el-button>
- </template>
- <template slot-scope="scope" slot="menu">
- <el-button
- type="text"
- icon="el-icon-circle-plus-outline"
- size="small"
- @click.stop="handleAdd(scope.row,scope.index)"
- v-if="userInfo.role_name.includes('admin')"
- >新增子项
- </el-button>
- </template>
- <template slot-scope="{row}"
- slot="deptCategory">
- <el-tag>{{row.deptCategoryName}}</el-tag>
- </template>
- <template slot-scope="{row}"
- slot="polCnNameForm">
- <search-query :datalist="polData"
- :selectValue="form.polCnName"
- :filterable="true"
- :clearable="true"
- :remote="true"
- :buttonIf="false"
- :forParameter="{key:'id',label:'cnName',value:'cnName'}"
- @remoteMethod="polBportsListfun($event,'polCnName')"
- @corpChange="corpChange($event,'polCnName')"
- @corpFocus="polBportsListfun($event,'polCnName')" >
- </search-query>
- </template>
- </avue-crud>
- </basic-container>
- </div>
- </template>
- <script>
- import {
- getLazyList,
- remove,
- update,
- add,
- getDept,
- getDeptTree
- } from "@/api/system/dept";
- import {mapGetters} from "vuex";
- import website from '@/config/website';
- import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
- import {bportsList} from "@/api/iosBasicData/bports";
- import {getToken} from "@/util/auth";
- export default {
- components: {SearchQuery},
- data() {
- return {
- // 装货港数据
- polData:[],
- form: {},
- selectionList: [],
- query: {},
- loading: true,
- parentId: 0,
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0,
- },
- option: {
- lazy: true,
- tip: false,
- simplePage: true,
- searchShow: true,
- searchMenuSpan: 6,
- tree: true,
- border: true,
- index: true,
- selection: true,
- viewBtn: true,
- menuWidth: 300,
- dialogClickModal: false,
- column: [
- {
- label: "机构名称",
- prop: "deptName",
- search: true,
- rules: [{
- required: true,
- message: "请输入机构名称",
- trigger: "blur"
- }]
- },
- {
- label: "所属租户",
- prop: "tenantId",
- type: "tree",
- dicUrl: "/api/blade-system/tenant/select",
- addDisplay: false,
- editDisplay: false,
- viewDisplay: website.tenantMode,
- span: 24,
- props: {
- label: "tenantName",
- value: "tenantId"
- },
- hide: !website.tenantMode,
- search: website.tenantMode,
- rules: [{
- required: true,
- message: "请输入所属租户",
- trigger: "click"
- }]
- },
- {
- label: "机构全称",
- prop: "fullName",
- search: true,
- rules: [{
- required: true,
- message: "请输入机构全称",
- trigger: "blur"
- }]
- },
- {
- label: "上级机构",
- prop: "parentId",
- dicData: [],
- type: "tree",
- hide: true,
- addDisabled: false,
- props: {
- label: "title"
- },
- rules: [{
- required: false,
- message: "请选择上级机构",
- trigger: "click"
- }]
- },
- {
- label: "机构类型",
- type: "select",
- dicUrl: "/api/blade-system/dict/dictionary?code=org_category",
- props: {
- label: "dictValue",
- value: "dictKey"
- },
- dataType: "number",
- width: 120,
- prop: "deptCategory",
- slot: true,
- rules: [{
- required: true,
- message: "请输入机构类型",
- trigger: "blur"
- }]
- },
- {
- label: "积分余额",
- prop: "pointsBalance",
- disabled:true,
- hide: true, // 表格里是否可见
- addDisplay:false,//当前行数据在新增表单中是否可见
- editDisplay:false,//当前行数据在编辑表单中是否可见
- viewDisplay:false, // 当前行数据在查看表单中是否可见
- value:0
- },
- {
- label: "装货港",
- prop: "polCnName",
- type: "select",
- formslot:true,
- disabled:true,
- hide: true, // 表格里是否可见
- addDisplay:false,//当前行数据在新增表单中是否可见
- editDisplay:false,//当前行数据在编辑表单中是否可见
- viewDisplay:false, // 当前行数据在查看表单中是否可见
- },
- {
- label: "英文全称",
- prop: "englishFullName",
- overHidden:true,
- },
- {
- label: "联系电话",
- prop: "tel",
- overHidden:true,
- },
- {
- label: "fax",
- prop: "fax",
- overHidden:true,
- },
- {
- label: "邮箱",
- prop: "email",
- overHidden:true,
- },
- {
- label: "网站",
- prop: "website",
- overHidden:true,
- },
- {
- label: "开户银行",
- prop: "bankOfDeposit",
- overHidden:true,
- },
- {
- label: "银行地址",
- prop: "bankAddress",
- overHidden:true,
- },
- {
- label: "人民币账号",
- prop: "rmbAccount",
- overHidden:true,
- },
- {
- label: "美金账号",
- prop: "usdAccount",
- overHidden:true,
- },
- {
- label: "swift代码",
- prop: "swiftCode",
- overHidden:true,
- },
- {
- label: "logo地址",
- prop: "logoUrl",
- type: "upload",
- listType: "picture-img",
- tip: "只能上传jpg/png/jpeg文件,且不超过2M",
- action: "/api/blade-resource/oss/endpoint/put-file",
- dataType: "string",
- propsHttp: {
- res: "data",
- url: "link"
- },
- },
- {
- label: "排序",
- prop: "sort",
- type: "number",
- align: "right",
- width: 60,
- rules: [{
- required: true,
- message: "请输入排序",
- trigger: "blur"
- }]
- },
- {
- label: "备注",
- prop: "remark",
- rules: [{
- required: false,
- message: "请输入备注",
- trigger: "blur"
- }],
- hide: true
- }
- ]
- },
- data: []
- };
- },
- created() {
- // 判断是否是admin 权限
- let arr = localStorage.getItem('roleName').split(',')
- // 根据 租户好判断是否要显示 积分余额
- const content = JSON.parse(localStorage.getItem('saber-tenantId')).content
- this.$nextTick(()=>{
- if (arr.indexOf('admin') != -1) {
- this.findObject(this.option.column, "pointsBalance").disabled = false
- }
- this.findObject(this.option.column, "pointsBalance").hide = false
- this.findObject(this.option.column, "pointsBalance").addDisplay = true
- this.findObject(this.option.column, "pointsBalance").editDisplay = true
- this.findObject(this.option.column, "pointsBalance").viewDisplay = true
- })
- // if (content == 171757) {
- // this.$nextTick(()=>{
- // if (arr.indexOf('admin') != -1) {
- // this.findObject(this.option.column, "pointsBalance").disabled = false
- // }
- // this.findObject(this.option.column, "pointsBalance").hide = false
- // this.findObject(this.option.column, "pointsBalance").addDisplay = true
- // this.findObject(this.option.column, "pointsBalance").editDisplay = true
- // this.findObject(this.option.column, "pointsBalance").viewDisplay = true
- // })
- // }
- // 判断是否显示装货港
- if (content == 409341) {
- this.$nextTick(()=>{
- this.findObject(this.option.column, "polCnName").hide = false
- this.findObject(this.option.column, "polCnName").addDisplay = true
- this.findObject(this.option.column, "polCnName").editDisplay = true
- this.findObject(this.option.column, "polCnName").viewDisplay = true
- })
- }
- },
- computed: {
- ...mapGetters(["userInfo", "permission"]),
- permissionList() {
- return {
- addBtn: this.vaildData(this.permission.dept_add, false),
- viewBtn: this.vaildData(this.permission.dept_view, false),
- delBtn: this.vaildData(this.permission.dept_delete, false),
- editBtn: this.vaildData(this.permission.dept_edit, false)
- };
- },
- ids() {
- let ids = [];
- this.selectionList.forEach(ele => {
- ids.push(ele.id);
- });
- return ids.join(",");
- }
- },
- methods: {
- // 装货港数据
- polBportsListfun(enName){
- bportsList(1,10,{enName}).then(res=>{
- this.polData = res.data.data.records
- })
- },
- // 装货港回调数据
- corpChange(value,name){
- for(let item of this.polData) {
- if (item.cnName == value) {
- this.form.polId = item.id
- this.form.polCnName = item.cnName
- this.form.polEnName = item.enName
- this.form.polCode = item.code
- this.form.polNamePrint = item.enName
- }
- }
- },
- initData() {
- getDeptTree().then(res => {
- const column = this.findObject(this.option.column, "parentId");
- column.dicData = res.data.data;
- });
- },
- handleAdd(row) {
- this.parentId = row.id;
- const column = this.findObject(this.option.column, "parentId");
- column.value = row.id;
- column.addDisabled = true;
- this.$refs.crud.rowAdd();
- },
- rowSave(row, done, loading) {
- add(row).then((res) => {
- // 获取新增数据的相关字段
- const data = res.data.data;
- row.id = data.id;
- row.deptCategoryName = data.deptCategoryName;
- row.tenantId = data.tenantId;
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- // 数据回调进行刷新
- done(row);
- }, error => {
- window.console.log(error);
- loading();
- });
- },
- rowUpdate(row, index, done, loading) {
- update(row).then(() => {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- // 数据回调进行刷新
- done(row);
- }, error => {
- window.console.log(error);
- loading();
- });
- },
- rowDel(row, index, done) {
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(row.id);
- })
- .then(() => {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- // 数据回调进行刷新
- done(row);
- });
- },
- handleDelete() {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(this.ids);
- })
- .then(() => {
- // 刷新表格数据并重载
- this.data = [];
- this.parentId = 0;
- this.$refs.crud.refreshTable();
- this.$refs.crud.toggleSelection();
- // 表格数据重载
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- });
- },
- searchReset() {
- this.query = {};
- this.parentId = 0;
- this.onLoad(this.page);
- },
- searchChange(params, done) {
- this.query = params;
- this.parentId = '';
- this.page.currentPage = 1;
- this.onLoad(this.page, params);
- done();
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- selectionClear() {
- this.selectionList = [];
- this.$refs.crud.toggleSelection();
- },
- beforeOpen(done, type) {
- if (["add", "edit"].includes(type)) {
- this.initData();
- }
- if (["edit", "view"].includes(type)) {
- getDept(this.form.id).then(res => {
- this.form = res.data.data;
- });
- }
- done();
- },
- beforeClose(done) {
- this.parentId = "";
- const column = this.findObject(this.option.column, "parentId");
- column.value = "";
- column.addDisabled = false;
- done();
- },
- currentChange(currentPage) {
- this.page.currentPage = currentPage;
- },
- sizeChange(pageSize) {
- this.page.pageSize = pageSize;
- },
- refreshChange() {
- this.onLoad(this.page, this.query);
- },
- onLoad(page, params = {}) {
- this.loading = true;
- getLazyList(this.parentId, Object.assign(params, this.query)).then(res => {
- this.data = res.data.data;
- this.loading = false;
- this.selectionClear();
- });
- },
- treeLoad(tree, treeNode, resolve) {
- const parentId = tree.id;
- getLazyList(parentId).then(res => {
- console.log(res.data.data)
- resolve(res.data.data);
- });
- }
- }
- };
- </script>
- <style>
- </style>
|