CreateFloder.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div>
  3. <div>
  4. <el-dialog v-model="addBoser" title="新建文件夹" width="30%" @close="diClose">
  5. <el-form :model="boserForm" label-width="120px">
  6. <el-form-item label="目录名称">
  7. <el-input v-model="boserForm.dirName" />
  8. </el-form-item>
  9. <!-- <el-form-item label="目录分类">
  10. <el-radio-group v-model="boserForm.dirType">
  11. <el-radio :label="1">公开目录</el-radio>
  12. <el-radio :label="2">组织目录</el-radio>
  13. </el-radio-group>
  14. </el-form-item> -->
  15. <el-form-item label="是否加密" v-if="!(FolderRole && !free )">
  16. <el-switch v-model="boserForm.isEncrypt" active-value="Y" inactive-value="N" />
  17. </el-form-item>
  18. <el-form-item label="加密等级" v-if="!(FolderRole && !free)">
  19. <el-radio-group v-model="boserForm.encryptLevel">
  20. <el-radio :label="item.levelCode" v-for="item in levelList" :key="item">{{item.levelName}}</el-radio>
  21. </el-radio-group>
  22. </el-form-item>
  23. </el-form>
  24. <template #footer>
  25. <span class="dialog-footer">
  26. <el-button @click="addBack">取消</el-button>
  27. <el-button type="primary" @click="sureAddBoser">
  28. 确认
  29. </el-button>
  30. </span>
  31. </template>
  32. </el-dialog>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import { ref, onMounted, toRef } from 'vue';
  38. import documents from '../../../api/document/document';
  39. import { getLevel } from '@/api/level/level.js';
  40. import { ElMessage } from 'element-plus';
  41. export default {
  42. props: {
  43. folderCase: {
  44. type: Boolean,
  45. required: true
  46. },
  47. oneOrTwo: {
  48. type: Number,
  49. required: true
  50. },
  51. impDirId: {
  52. type: Number,
  53. required: true
  54. },
  55. impSpaceId: {
  56. type: Number,
  57. required: true
  58. },
  59. newDirId: {
  60. type: Number,
  61. required: true
  62. },
  63. newSpaceId: {
  64. type: Number,
  65. required: true
  66. },
  67. thisFolderRole: {
  68. type: Object,
  69. required: true,
  70. default: ()=>{},
  71. },
  72. getAllTop: Function,
  73. },
  74. setup(props, { emit }) {
  75. let { addBack, sureAddBoser, diClose } = toRef(props)
  76. let result = props.folderCase
  77. let free = props.oneOrTwo
  78. let spId = props.impSpaceId
  79. let drId = props.impDirId
  80. let newspid = props.newSpaceId
  81. let newdrid = props.newDirId
  82. const FolderRole = props.thisFolderRole
  83. console.log("FolderRole",props);
  84. let addBoser = ref(false)
  85. let boserForm = ref({
  86. dirName: "",
  87. dirType:1,
  88. isEncrypt:"Y",
  89. encryptLevel:"L1"
  90. })
  91. const levelList = ref([])
  92. function inital() {
  93. console.log(free, 'free');
  94. addBoser.value = result
  95. }
  96. function backTo() {
  97. addBoser.value = false
  98. emit("getChildrenC", addBoser.value)
  99. }
  100. function addFloder() {
  101. if (boserForm.value.dirName === '') {
  102. ElMessage({
  103. type: "error",
  104. message: "目录名称不能为空"
  105. })
  106. } else {
  107. if (free === 1) {
  108. documents.addDocument(
  109. {
  110. "dirName": boserForm.value.dirName,
  111. "parentId": drId - 0,
  112. "spaceId": spId - 0,
  113. "isEncrypt":boserForm.value.isEncrypt,
  114. "encryptLevel":boserForm.value.isEncrypt == "Y"?boserForm.value.encryptLevel:null
  115. }
  116. ).then(res => {
  117. if (res.code === 200) {
  118. ElMessage({
  119. message: '添加一级目录成功',
  120. type: 'success',
  121. })
  122. }
  123. addBoser.value = false
  124. emit("getChildrenC", addBoser.value)
  125. props.getAllTop()
  126. })
  127. } else {
  128. let query = {}
  129. if(FolderRole){
  130. query={
  131. "dirName": boserForm.value.dirName,
  132. "parentId": newdrid - 0,
  133. "spaceId": newspid - 0,
  134. "isEncrypt":"Y",
  135. "encryptLevel":FolderRole.levelCode
  136. }
  137. console.log('query',query);
  138. console.log('FolderRole',FolderRole);
  139. }else{
  140. query={
  141. "dirName": boserForm.value.dirName,
  142. "parentId": newdrid - 0,
  143. "spaceId": newspid - 0,
  144. "isEncrypt":boserForm.value.isEncrypt,
  145. "encryptLevel":boserForm.value.isEncrypt == "Y"?boserForm.value.encryptLevel:null
  146. }
  147. }
  148. documents.addDocument(
  149. query
  150. ).then(res => {
  151. if (res.code === 200) {
  152. ElMessage({
  153. message: '添加成功',
  154. type: 'success',
  155. })
  156. }
  157. addBoser.value = false
  158. emit("getChildrenC", addBoser.value)
  159. props.getAllTop()
  160. })
  161. }
  162. }
  163. }
  164. const getLevelList = async ()=>{
  165. const res = await getLevel()
  166. if(res.rows){
  167. levelList.value = res.rows
  168. }
  169. // console.log(res);
  170. }
  171. onMounted(() => {
  172. inital()
  173. getLevelList()
  174. })
  175. return {
  176. addBoser,
  177. boserForm,
  178. inital,
  179. addBack: backTo,
  180. sureAddBoser: addFloder,
  181. diClose: backTo,
  182. spId,
  183. drId,
  184. newdrid,
  185. newspid,
  186. levelList,
  187. getLevelList,
  188. FolderRole,
  189. free
  190. }
  191. }
  192. }
  193. </script>
  194. <style lang="scss" scoped></style>