数字化园区前端项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OtherInfo.vue 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <!-- 其他信息 -->
  2. <template>
  3. <div class="basic_info_box">
  4. <div class="title">
  5. 其他信息:
  6. </div>
  7. <table class="table_box" cellspacing="0">
  8. <tr>
  9. <td class="table_title">企业优势:</td>
  10. <td class="content">
  11. <el-input
  12. :disabled="!isEditing"
  13. type="textarea"
  14. v-model="companyInfo.enterpriseAdvantage"
  15. ></el-input>
  16. </td>
  17. </tr>
  18. <tr>
  19. <td class="table_title">企业文化:</td>
  20. <td class="content">
  21. <el-input
  22. :disabled="!isEditing"
  23. type="textarea"
  24. v-model="companyInfo.enterpriseCulture"
  25. ></el-input>
  26. </td>
  27. </tr>
  28. <tr>
  29. <td class="table_title">企业风采:</td>
  30. <td class="content">
  31. <template v-if="!isEditing">
  32. <img
  33. v-for="(item, index) in uploadFileList"
  34. :key="index"
  35. class="company_img"
  36. :src="item"
  37. alt="企业风采"
  38. />
  39. </template>
  40. <div v-else class="img_box">
  41. <!-- <img
  42. v-for="(item, index) in uploadFileList"
  43. :key="index"
  44. class="company_img"
  45. :src="item"
  46. /> -->
  47. <el-upload
  48. :limit="5"
  49. class="avatar-uploader"
  50. :file-list="fileList"
  51. action="#"
  52. list-type="picture-card"
  53. accept=".jpg,.png,.jpeg"
  54. :http-request="
  55. file => {
  56. afterReadUrl(file);
  57. }
  58. "
  59. :before-remove="handleBeforeRemove"
  60. >
  61. <div slot="default" class="upload_text">
  62. <img
  63. class="company_img"
  64. src="@assets/image/company/bg_upload.png"
  65. alt=""
  66. />
  67. </div>
  68. </el-upload>
  69. </div>
  70. </td>
  71. </tr>
  72. <tr>
  73. <td class="table_title">其他信息:</td>
  74. <td class="content">
  75. <div>
  76. <el-input
  77. :disabled="!isEditing"
  78. type="textarea"
  79. v-model="companyInfo.otherInfo"
  80. ></el-input>
  81. </div>
  82. </td>
  83. </tr>
  84. </table>
  85. <el-dialog :visible.sync="dialogVisible">
  86. <img width="100%" :src="dialogImageUrl" alt="" />
  87. </el-dialog>
  88. </div>
  89. </template>
  90. <script>
  91. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  92. //例如:import 《组件名称》 from '《组件路径》';
  93. import { uploadFile } from "@mixin/uploadFile";
  94. export default {
  95. props: {
  96. companyInfo: {
  97. type: Object,
  98. default: () => {},
  99. },
  100. isEditing: {
  101. type: Boolean,
  102. default: false,
  103. },
  104. },
  105. //import引入的组件需要注入到对象中才能使用
  106. components: {},
  107. mixins: [uploadFile],
  108. data() {
  109. //这里存放数据
  110. return {
  111. fileList: [],
  112. uploadFileList: [], // 上传的图片数组
  113. dialogImageUrl: "",
  114. dialogVisible: false,
  115. };
  116. },
  117. //监听属性 类似于data概念
  118. computed: {},
  119. //监控data中的数据变化
  120. watch: {},
  121. //方法集合
  122. methods: {
  123. // 删除图片
  124. handleBeforeRemove(file, fileList) {
  125. console.log(fileList);
  126. const index = fileList.findIndex(e => e.uid === file.uid);
  127. this.uploadFileList.splice(index, 1);
  128. },
  129. handlePictureCardPreview(file) {
  130. this.dialogImageUrl = file.url;
  131. this.dialogVisible = true;
  132. },
  133. async afterReadUrl(file) {
  134. let photo2Url = await this.uploadFile(file, null);
  135. this.uploadFileList.push(photo2Url);
  136. console.log(this.uploadFileList);
  137. },
  138. },
  139. //生命周期 - 创建完成(可以访问当前this实例)
  140. created() {
  141. this.uploadFileList = JSON.parse(this.companyInfo.enterpriseFeatures);
  142. this.uploadFileList.forEach(item => {
  143. this.fileList.push({
  144. url: item,
  145. });
  146. });
  147. },
  148. //生命周期 - 挂载完成(可以访问DOM元素)
  149. mounted() {},
  150. };
  151. </script>
  152. <style lang="scss" scoped>
  153. //@import url(); 引入公共css类
  154. .basic_info_box {
  155. width: 100%;
  156. .title {
  157. @include font(16px, #334a5f);
  158. font-weight: 600;
  159. padding: 20px 0;
  160. @include border-box;
  161. }
  162. .table_box {
  163. width: 100%;
  164. border: 1px solid #bcd8e9;
  165. tr {
  166. height: 48px;
  167. td {
  168. @include font(14px, #334a5f);
  169. padding: 10px;
  170. @include border-box;
  171. }
  172. > td + td {
  173. border-left: 1px solid #bcd8e9;
  174. }
  175. }
  176. > tr + tr {
  177. td {
  178. border-top: 1px solid #bcd8e9;
  179. }
  180. }
  181. .table_title {
  182. height: 48px;
  183. @include font(14px, #637485);
  184. @include size(110px, auto);
  185. background: #f2f7fb;
  186. text-align: center;
  187. }
  188. .content {
  189. padding: 20px;
  190. @include border-box;
  191. .avatar-uploader {
  192. // @include size(120px, 96px);
  193. @include flex(row, flex-start, center, wrap);
  194. .upload_text {
  195. @include border-box;
  196. @include size(120px, 96px);
  197. }
  198. ::v-deep .el-upload {
  199. @include size(120px, 96px);
  200. cursor: pointer;
  201. position: relative;
  202. overflow: hidden;
  203. margin-bottom: 8px;
  204. }
  205. }
  206. ::v-deep .el-upload-list--picture-card {
  207. display: inline-flex;
  208. }
  209. ::v-deep .el-upload-list--picture-card .el-upload-list__item {
  210. @include size(120px, 96px);
  211. border: none;
  212. border-radius: 0px;
  213. margin-right: 25px;
  214. > div {
  215. width: 100%;
  216. height: 100%;
  217. }
  218. }
  219. ::v-deep .el-upload--picture-card {
  220. border: none;
  221. }
  222. .company_img {
  223. @include size(120px, 96px);
  224. margin-right: 25px;
  225. }
  226. }
  227. ::v-deep .el-textarea.is-disabled .el-textarea__inner {
  228. background: #fff;
  229. border: none;
  230. @include font(14px, #334a5f);
  231. }
  232. }
  233. }
  234. </style>