dept.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <template>
  2. <div>
  3. <basic-container>
  4. <avue-crud :option="option"
  5. :table-loading="loading"
  6. :data="data"
  7. ref="crud"
  8. v-model="form"
  9. :permission="permissionList"
  10. :before-open="beforeOpen"
  11. :before-close="beforeClose"
  12. @row-del="rowDel"
  13. @row-update="rowUpdate"
  14. @row-save="rowSave"
  15. @search-change="searchChange"
  16. @search-reset="searchReset"
  17. @selection-change="selectionChange"
  18. @current-change="currentChange"
  19. @size-change="sizeChange"
  20. @refresh-change="refreshChange"
  21. @on-load="onLoad"
  22. @tree-load="treeLoad">
  23. <template slot="menuLeft">
  24. <el-button type="danger"
  25. size="small"
  26. icon="el-icon-delete"
  27. v-if="permission.dept_delete"
  28. plain
  29. @click="handleDelete">删 除
  30. </el-button>
  31. </template>
  32. <template slot-scope="scope" slot="menu">
  33. <el-button
  34. type="text"
  35. icon="el-icon-circle-plus-outline"
  36. size="small"
  37. @click.stop="handleAdd(scope.row,scope.index)"
  38. v-if="userInfo.role_name.includes('admin')"
  39. >新增子项
  40. </el-button>
  41. </template>
  42. <template slot-scope="{row}"
  43. slot="deptCategory">
  44. <el-tag>{{row.deptCategoryName}}</el-tag>
  45. </template>
  46. <template slot-scope="{row}"
  47. slot="polCnNameForm">
  48. <search-query :datalist="polData"
  49. :selectValue="form.polCnName"
  50. :filterable="true"
  51. :clearable="true"
  52. :remote="true"
  53. :buttonIf="false"
  54. :forParameter="{key:'id',label:'cnName',value:'cnName'}"
  55. @remoteMethod="polBportsListfun($event,'polCnName')"
  56. @corpChange="corpChange($event,'polCnName')"
  57. @corpFocus="polBportsListfun($event,'polCnName')" >
  58. </search-query>
  59. </template>
  60. </avue-crud>
  61. </basic-container>
  62. </div>
  63. </template>
  64. <script>
  65. import {
  66. getLazyList,
  67. remove,
  68. update,
  69. add,
  70. getDept,
  71. getDeptTree
  72. } from "@/api/system/dept";
  73. import {mapGetters} from "vuex";
  74. import website from '@/config/website';
  75. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  76. import {bportsList} from "@/api/iosBasicData/bports";
  77. import {getToken} from "@/util/auth";
  78. export default {
  79. components: {SearchQuery},
  80. data() {
  81. return {
  82. // 装货港数据
  83. polData:[],
  84. form: {},
  85. selectionList: [],
  86. query: {},
  87. loading: true,
  88. parentId: 0,
  89. page: {
  90. pageSize: 10,
  91. currentPage: 1,
  92. total: 0,
  93. },
  94. option: {
  95. lazy: true,
  96. tip: false,
  97. simplePage: true,
  98. searchShow: true,
  99. searchMenuSpan: 6,
  100. tree: true,
  101. border: true,
  102. index: true,
  103. selection: true,
  104. viewBtn: true,
  105. menuWidth: 300,
  106. dialogClickModal: false,
  107. column: [
  108. {
  109. label: "机构名称",
  110. prop: "deptName",
  111. search: true,
  112. width: '100',
  113. rules: [{
  114. required: true,
  115. message: "请输入机构名称",
  116. trigger: "blur"
  117. }]
  118. },
  119. {
  120. label: "所属租户",
  121. prop: "tenantId",
  122. type: "tree",
  123. dicUrl: "/api/blade-system/tenant/select",
  124. addDisplay: false,
  125. editDisplay: false,
  126. viewDisplay: website.tenantMode,
  127. span: 24,
  128. props: {
  129. label: "tenantName",
  130. value: "tenantId"
  131. },
  132. hide: !website.tenantMode,
  133. search: website.tenantMode,
  134. rules: [{
  135. required: true,
  136. message: "请输入所属租户",
  137. trigger: "click"
  138. }]
  139. },
  140. {
  141. label: "机构全称",
  142. prop: "fullName",
  143. search: true,
  144. overHidden:true,
  145. rules: [{
  146. required: true,
  147. message: "请输入机构全称",
  148. trigger: "blur"
  149. }]
  150. },
  151. {
  152. label: "上级机构",
  153. prop: "parentId",
  154. dicData: [],
  155. type: "tree",
  156. hide: true,
  157. addDisabled: false,
  158. props: {
  159. label: "title"
  160. },
  161. rules: [{
  162. required: false,
  163. message: "请选择上级机构",
  164. trigger: "click"
  165. }]
  166. },
  167. {
  168. label: "机构类型",
  169. type: "select",
  170. dicUrl: "/api/blade-system/dict/dictionary?code=org_category",
  171. props: {
  172. label: "dictValue",
  173. value: "dictKey"
  174. },
  175. dataType: "number",
  176. width: 120,
  177. prop: "deptCategory",
  178. slot: true,
  179. rules: [{
  180. required: true,
  181. message: "请输入机构类型",
  182. trigger: "blur"
  183. }]
  184. },
  185. {
  186. label: "积分余额",
  187. prop: "pointsBalance",
  188. disabled:true,
  189. hide: true, // 表格里是否可见
  190. addDisplay:false,//当前行数据在新增表单中是否可见
  191. editDisplay:false,//当前行数据在编辑表单中是否可见
  192. viewDisplay:false, // 当前行数据在查看表单中是否可见
  193. value:0
  194. },
  195. {
  196. label: "装货港",
  197. prop: "polCnName",
  198. type: "select",
  199. formslot:true,
  200. disabled:true,
  201. hide: true, // 表格里是否可见
  202. addDisplay:false,//当前行数据在新增表单中是否可见
  203. editDisplay:false,//当前行数据在编辑表单中是否可见
  204. viewDisplay:false, // 当前行数据在查看表单中是否可见
  205. },
  206. {
  207. label: "英文全称",
  208. prop: "englishFullName",
  209. overHidden:true,
  210. },
  211. {
  212. label: "联系电话",
  213. prop: "tel",
  214. overHidden:true,
  215. },
  216. {
  217. label: "公司地址",
  218. prop: "address",
  219. overHidden:true,
  220. },
  221. {
  222. label: "fax",
  223. prop: "fax",
  224. overHidden:true,
  225. },
  226. {
  227. label: "邮箱",
  228. prop: "email",
  229. overHidden:true,
  230. },
  231. {
  232. label: "网站",
  233. prop: "website",
  234. overHidden:true,
  235. },
  236. {
  237. label: "开户银行",
  238. prop: "bankOfDeposit",
  239. overHidden:true,
  240. },
  241. {
  242. label: "银行地址",
  243. prop: "bankAddress",
  244. overHidden:true,
  245. },
  246. {
  247. label: "开户银行美金",
  248. prop: "bankOfDepositUsd",
  249. width: '100',
  250. overHidden:true,
  251. },
  252. {
  253. label: "银行地址美金",
  254. prop: "bankAddressUsd",
  255. width: '100',
  256. overHidden:true,
  257. },
  258. {
  259. label: "人民币账号",
  260. prop: "rmbAccount",
  261. width: '100',
  262. overHidden:true,
  263. },
  264. {
  265. label: "美金账号",
  266. prop: "usdAccount",
  267. overHidden:true,
  268. },
  269. {
  270. label: "swift代码",
  271. prop: "swiftCode",
  272. overHidden:true,
  273. },
  274. {
  275. label: "logo",
  276. prop: "logoUrl",
  277. type: "upload",
  278. listType: "picture-img",
  279. tip: "只能上传jpg/png/jpeg文件,且不超过2M",
  280. action: "/api/blade-resource/oss/endpoint/put-file",
  281. dataType: "string",
  282. propsHttp: {
  283. res: "data",
  284. url: "link"
  285. },
  286. },
  287. {
  288. label: "排序",
  289. prop: "sort",
  290. type: "number",
  291. align: "right",
  292. width: 60,
  293. rules: [{
  294. required: true,
  295. message: "请输入排序",
  296. trigger: "blur"
  297. }]
  298. },
  299. {
  300. label: "备注",
  301. prop: "remark",
  302. rules: [{
  303. required: false,
  304. message: "请输入备注",
  305. trigger: "blur"
  306. }],
  307. hide: true
  308. }
  309. ]
  310. },
  311. data: []
  312. };
  313. },
  314. created() {
  315. // 判断是否是admin 权限
  316. let arr = localStorage.getItem('roleName').split(',')
  317. // 根据 租户好判断是否要显示 积分余额
  318. const content = JSON.parse(localStorage.getItem('saber-tenantId')).content
  319. this.$nextTick(()=>{
  320. if (arr.indexOf('admin') != -1) {
  321. this.findObject(this.option.column, "pointsBalance").disabled = false
  322. }
  323. this.findObject(this.option.column, "pointsBalance").hide = false
  324. this.findObject(this.option.column, "pointsBalance").addDisplay = true
  325. this.findObject(this.option.column, "pointsBalance").editDisplay = true
  326. this.findObject(this.option.column, "pointsBalance").viewDisplay = true
  327. })
  328. // if (content == 171757) {
  329. // this.$nextTick(()=>{
  330. // if (arr.indexOf('admin') != -1) {
  331. // this.findObject(this.option.column, "pointsBalance").disabled = false
  332. // }
  333. // this.findObject(this.option.column, "pointsBalance").hide = false
  334. // this.findObject(this.option.column, "pointsBalance").addDisplay = true
  335. // this.findObject(this.option.column, "pointsBalance").editDisplay = true
  336. // this.findObject(this.option.column, "pointsBalance").viewDisplay = true
  337. // })
  338. // }
  339. // 判断是否显示装货港
  340. if (localStorage.getItem('sysitemType') == 12) {
  341. this.$nextTick(()=>{
  342. this.findObject(this.option.column, "polCnName").hide = false
  343. this.findObject(this.option.column, "polCnName").addDisplay = true
  344. this.findObject(this.option.column, "polCnName").editDisplay = true
  345. this.findObject(this.option.column, "polCnName").viewDisplay = true
  346. })
  347. }
  348. },
  349. computed: {
  350. ...mapGetters(["userInfo", "permission"]),
  351. permissionList() {
  352. return {
  353. addBtn: this.vaildData(this.permission.dept_add, false),
  354. viewBtn: this.vaildData(this.permission.dept_view, false),
  355. delBtn: this.vaildData(this.permission.dept_delete, false),
  356. editBtn: this.vaildData(this.permission.dept_edit, false)
  357. };
  358. },
  359. ids() {
  360. let ids = [];
  361. this.selectionList.forEach(ele => {
  362. ids.push(ele.id);
  363. });
  364. return ids.join(",");
  365. }
  366. },
  367. methods: {
  368. // 装货港数据
  369. polBportsListfun(enName){
  370. bportsList(1,10,{enName}).then(res=>{
  371. this.polData = res.data.data.records
  372. })
  373. },
  374. // 装货港回调数据
  375. corpChange(value,name){
  376. for(let item of this.polData) {
  377. if (item.cnName == value) {
  378. this.form.polId = item.id
  379. this.form.polCnName = item.cnName
  380. this.form.polEnName = item.enName
  381. this.form.polCode = item.code
  382. this.form.polNamePrint = item.enName
  383. }
  384. }
  385. },
  386. initData() {
  387. getDeptTree().then(res => {
  388. const column = this.findObject(this.option.column, "parentId");
  389. column.dicData = res.data.data;
  390. });
  391. },
  392. handleAdd(row) {
  393. this.parentId = row.id;
  394. const column = this.findObject(this.option.column, "parentId");
  395. column.value = row.id;
  396. column.addDisabled = true;
  397. this.$refs.crud.rowAdd();
  398. },
  399. rowSave(row, done, loading) {
  400. add(row).then((res) => {
  401. // 获取新增数据的相关字段
  402. const data = res.data.data;
  403. row.id = data.id;
  404. row.deptCategoryName = data.deptCategoryName;
  405. row.tenantId = data.tenantId;
  406. this.$message({
  407. type: "success",
  408. message: "操作成功!"
  409. });
  410. // 数据回调进行刷新
  411. done(row);
  412. }, error => {
  413. window.console.log(error);
  414. loading();
  415. });
  416. },
  417. rowUpdate(row, index, done, loading) {
  418. update(row).then(() => {
  419. this.$message({
  420. type: "success",
  421. message: "操作成功!"
  422. });
  423. // 数据回调进行刷新
  424. done(row);
  425. }, error => {
  426. window.console.log(error);
  427. loading();
  428. });
  429. },
  430. rowDel(row, index, done) {
  431. this.$confirm("确定将选择数据删除?", {
  432. confirmButtonText: "确定",
  433. cancelButtonText: "取消",
  434. type: "warning"
  435. })
  436. .then(() => {
  437. return remove(row.id);
  438. })
  439. .then(() => {
  440. this.$message({
  441. type: "success",
  442. message: "操作成功!"
  443. });
  444. // 数据回调进行刷新
  445. done(row);
  446. });
  447. },
  448. handleDelete() {
  449. if (this.selectionList.length === 0) {
  450. this.$message.warning("请选择至少一条数据");
  451. return;
  452. }
  453. this.$confirm("确定将选择数据删除?", {
  454. confirmButtonText: "确定",
  455. cancelButtonText: "取消",
  456. type: "warning"
  457. })
  458. .then(() => {
  459. return remove(this.ids);
  460. })
  461. .then(() => {
  462. // 刷新表格数据并重载
  463. this.data = [];
  464. this.parentId = 0;
  465. this.$refs.crud.refreshTable();
  466. this.$refs.crud.toggleSelection();
  467. // 表格数据重载
  468. this.onLoad(this.page);
  469. this.$message({
  470. type: "success",
  471. message: "操作成功!"
  472. });
  473. });
  474. },
  475. searchReset() {
  476. this.query = {};
  477. this.parentId = 0;
  478. this.onLoad(this.page);
  479. },
  480. searchChange(params, done) {
  481. this.query = params;
  482. this.parentId = '';
  483. this.page.currentPage = 1;
  484. this.onLoad(this.page, params);
  485. done();
  486. },
  487. selectionChange(list) {
  488. this.selectionList = list;
  489. },
  490. selectionClear() {
  491. this.selectionList = [];
  492. this.$refs.crud.toggleSelection();
  493. },
  494. beforeOpen(done, type) {
  495. if (["add", "edit"].includes(type)) {
  496. this.initData();
  497. }
  498. if (["edit", "view"].includes(type)) {
  499. getDept(this.form.id).then(res => {
  500. this.form = res.data.data;
  501. });
  502. }
  503. done();
  504. },
  505. beforeClose(done) {
  506. this.parentId = "";
  507. const column = this.findObject(this.option.column, "parentId");
  508. column.value = "";
  509. column.addDisabled = false;
  510. done();
  511. },
  512. currentChange(currentPage) {
  513. this.page.currentPage = currentPage;
  514. },
  515. sizeChange(pageSize) {
  516. this.page.pageSize = pageSize;
  517. },
  518. refreshChange() {
  519. this.onLoad(this.page, this.query);
  520. },
  521. onLoad(page, params = {}) {
  522. this.loading = true;
  523. getLazyList(this.parentId, Object.assign(params, this.query)).then(res => {
  524. this.data = res.data.data;
  525. this.loading = false;
  526. this.selectionClear();
  527. });
  528. },
  529. treeLoad(tree, treeNode, resolve) {
  530. const parentId = tree.id;
  531. getLazyList(parentId).then(res => {
  532. console.log(res.data.data)
  533. resolve(res.data.data);
  534. });
  535. }
  536. }
  537. };
  538. </script>
  539. <style>
  540. </style>