dialog.select.file.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <DialogCom
  3. title="选取知识库文件"
  4. :visible.sync="isShow"
  5. class="g-dialog-select-safe-check"
  6. :close-on-click-modal="false"
  7. width="55%"
  8. top="10vh"
  9. append-to-body
  10. >
  11. <div class="el-dialog-div" style="margin-bottom:20px">
  12. <g-search-table
  13. ref="st"
  14. url="/core/materials/fileList"
  15. method="post"
  16. :search-data="search"
  17. :pageable="true"
  18. :select="true"
  19. :select-default="selectList"
  20. :drag="false"
  21. @select="onSelect"
  22. >
  23. <!-- 搜索 -->
  24. <template slot="searchs">
  25. <el-form-item prop="title" label="资料名称">
  26. <el-input v-model="search.title" placeholder="请输入资料名称"/>
  27. </el-form-item>
  28. <el-form-item prop="fileName" label="文件名称">
  29. <el-input v-model="search.fileName" placeholder="请输入文件名称"/>
  30. </el-form-item>
  31. </template>
  32. <!-- 表格 -->
  33. <template slot="columns">
  34. <el-table-column
  35. prop="orgName"
  36. label="上传机构"
  37. width="250"
  38. ></el-table-column>
  39. <el-table-column label="资料名称" prop="title" width="300"> </el-table-column>
  40. <el-table-column
  41. label="文件名称"
  42. >
  43. <template slot-scope="scope">
  44. <template v-if="scope.row.fileList">
  45. <el-tag style="cursor: pointer;margin-right: 5px;" size="mini" type="success" effect="plain" @click="downLoadFile(JSON.parse(item).url)" v-for="(item, index) in scope.row.fileList"
  46. :key="index">
  47. {{ JSON.parse(item).name }}
  48. </el-tag>
  49. </template>
  50. </template>
  51. </el-table-column>
  52. <!-- <el-table-column prop="nfcName"
  53. label="采集点"
  54. width="120"></el-table-column>-->
  55. </template>
  56. </g-search-table>
  57. </div>
  58. <div slot="footer" class="dialog-footer">
  59. <el-button @click="onHide">关闭</el-button>
  60. <el-button type="primary" @click="onSubmit">确定</el-button>
  61. </div>
  62. </DialogCom>
  63. </template>
  64. <script>
  65. import GSearchTable from "@/components/table/gx.search.table.vue";
  66. // import { ruleListForOrg } from "@/api/resumption/rule.js";
  67. export default {
  68. components: { GSearchTable },
  69. data() {
  70. return {
  71. isShow: false,
  72. selectList: [],
  73. // ruleList: [],
  74. search: this.emptySearch(),
  75. };
  76. },
  77. computed: {},
  78. watch: {
  79. orgId(newval) {
  80. console.log("orgId",newval);
  81. this.search.orgId=newval;
  82. },
  83. },
  84. props: {
  85. defaultSelect:{
  86. type:Array
  87. },
  88. orgId:{
  89. },
  90. },
  91. methods: {
  92. show() {
  93. this.search= this.emptySearch();
  94. console.log("this.search",this.search)
  95. this.isShow = true;
  96. this.selectList =this.defaultSelect;
  97. // TODO: 处理第一次进入弹窗时,表格数据不加载
  98. },
  99. onHide() {
  100. this.isShow = false;
  101. this.search=this.emptySearch();
  102. },
  103. onSelect(item) {
  104. this.selectList = item;
  105. },
  106. onSubmit() {
  107. let s=this.selectList
  108. this.$emit("select", this.selectList);
  109. this.onHide();
  110. },
  111. emptySearch() {
  112. return {
  113. title: null,
  114. fileName: null,
  115. orgId:this.$store.getters.orgId,
  116. // t:new Date(),
  117. };
  118. },
  119. downLoadFile(url)
  120. {
  121. if(process.env.VUE_APP_BASE_API!=='/')
  122. {
  123. url=process.env.VUE_APP_BASE_API+url;
  124. }
  125. const a = document.createElement("a");
  126. a.setAttribute("download", name);
  127. a.setAttribute("target", "_blank");
  128. a.setAttribute("href", url);
  129. a.click();
  130. }
  131. },
  132. mounted() {
  133. },
  134. };
  135. </script>
  136. <style lang="scss" scoped>
  137. .el-dialog-div {
  138. overflow: auto;
  139. }
  140. </style>