addBuild.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <el-dialog
  3. :title="buildTitle"
  4. :visible.sync="buildDialogVis"
  5. id="messageDialog"
  6. width="50%"
  7. >
  8. <el-form
  9. :inline="true"
  10. :model="form"
  11. label-width="125px"
  12. :rules="rules"
  13. ref="ruleForm"
  14. >
  15. <template v-for="(val,key,index) in buildMessage">
  16. <h4>{{key}}</h4>
  17. <span
  18. :key="item.InfoPointCode"
  19. v-for="(item,index) in val"
  20. :class="[{'upload-file':item.InputMode == 'F2'}]"
  21. >
  22. <el-form-item
  23. :class="{FloorTypeSelect:item.InputMode == 'D1'||item.Unit}"
  24. :label="item.InfoPointName"
  25. :prop="item.InfoPointCode"
  26. v-if="all||item.Visible"
  27. >
  28. <el-input v-if="item.InputMode == 'B1' || item.InputMode == 'B2'" v-model="form[item.Path]"></el-input>
  29. <el-input type="number" v-else-if="item.InputMode == 'A1'||item.InputMode == 'A2'" v-model="form[item.Path]">
  30. <template slot="append" v-if="item.Unit">{{item.Unit}}</template>
  31. </el-input>
  32. <el-select placeholder="请选择" v-else-if="item.InputMode == 'D1'" v-model="form[item.Path]">
  33. <el-option :key="op.Code" :label="op.Name" :value="op.Code" v-for="op in item.options"></el-option>
  34. </el-select>
  35. <el-select placeholder="请选择" v-else-if="item.InputMode == 'D2'||item.InputMode == 'E2'"
  36. v-model="form[item.Path]" multiple
  37. collapse-tags>
  38. <el-option :key="op.Code" :label="op.Name" :value="op.Code" v-for="op in item.options"></el-option>
  39. </el-select>
  40. <el-date-picker
  41. v-model="form[item.Path]"
  42. type="daterange"
  43. v-else-if="item.InputMode == 'C6'"
  44. value-format="yyyy-MM-dd"
  45. range-separator="至"
  46. start-placeholder="开始日期"
  47. end-placeholder="结束日期"/>
  48. <el-cascader
  49. v-else-if="item.InputMode == 'D1L'"
  50. placeholder="请选择"
  51. :options="item.options"
  52. v-model="form[item.Path]"
  53. :props="{ checkStrictly: true ,value: 'Code',label:'Name'}"
  54. clearable
  55. />
  56. <el-input
  57. v-else-if="item.InputMode == 'L'||item.InputMode == 'L1'||item.InputMode == 'L2'||item.InputMode == 'M'"
  58. v-model="form[item.Path]">
  59. <template slot="append" v-if="item.Unit">{{item.Unit}}</template>
  60. </el-input>
  61. <el-date-picker
  62. placeholder="选择日期"
  63. value-format="yyyy-MM-dd"
  64. type="date" v-else-if="item.InputMode == 'C5'" v-model="form[item.Path]">
  65. </el-date-picker>
  66. <el-upload
  67. v-else-if="item.InputMode == 'F2'&& item.Path === 'BuildingInfo.BuildingType.Pic'"
  68. v-model="form[item.Path]"
  69. action="https://jsonplaceholder.typicode.com/posts/"
  70. list-type="picture-card"
  71. >
  72. <!-- :on-preview="handlePictureCardPreview"
  73. :on-remove="handleRemove"-->
  74. <i class="el-icon-plus"></i>
  75. </el-upload>
  76. <upload-files
  77. v-else-if="item.InputMode == 'F2'"
  78. v-model="form[item.Path]"
  79. :readOnly="false"
  80. :keysArr="keysArr"
  81. :show-file-list="false"
  82. @change="changeItem"
  83. max="2"
  84. />
  85. <el-input disabled title="暂不支持" v-else v-model="form[item.Path]"></el-input>
  86. </el-form-item>
  87. <!-- <span>{{item.InputMode}}</span>-->
  88. </span>
  89. </template>
  90. <!-- <h4>建筑信息-建筑类型</h4>-->
  91. <!-- <div>-->
  92. <!-- <p class="el-form-item__label"-->
  93. <!-- style="width: 125px"-->
  94. <!-- >建筑图片:</p>-->
  95. <!-- &lt;!&ndash; :on-preview="handlePictureCardPreview"&ndash;&gt;-->
  96. <!-- &lt;!&ndash; :on-remove="handleRemove"&ndash;&gt;-->
  97. <!-- <el-upload-->
  98. <!-- action="https://jsonplaceholder.typicode.com/posts/"-->
  99. <!-- list-type="picture-card"-->
  100. <!-- style="margin-left: 130px">-->
  101. <!-- <i class="el-icon-plus"/>-->
  102. <!-- </el-upload>-->
  103. <!-- <el-dialog :visible.sync="dialogVisible">-->
  104. <!-- <img-->
  105. <!-- :src="dialogImageUrl"-->
  106. <!-- alt=""-->
  107. <!-- width="100%"-->
  108. <!-- >-->
  109. <!-- </el-dialog>-->
  110. <!-- </div>-->
  111. <!-- <h4>建筑文档</h4>-->
  112. <!-- <uploadFile name="建筑图纸"/>-->
  113. <!-- <uploadFile name="档案"/>-->
  114. <!-- <uploadFile name="建筑能耗模型"/>-->
  115. </el-form>
  116. <span
  117. class="dialog-footer"
  118. slot="footer"
  119. >
  120. <el-button @click="buildDialogVis = false">取 消</el-button>
  121. <el-button @click="submitForm('ruleForm')" type="primary">确 定</el-button>
  122. </span>
  123. <el-dialog :visible.sync="dialogVisible">
  124. <img width="100%" :src="dialogImageUrl" alt="">
  125. </el-dialog>
  126. </el-dialog>
  127. </template>
  128. <script>
  129. import uploadFiles from "@/components/business_space/lib/uploadFiles";
  130. function flattenKeys(obj) {
  131. let res = {}
  132. function isObject(val) {
  133. return typeof val === 'object' && !Array.isArray(val)
  134. }
  135. function digKeys(prev, obj) {
  136. Object.entries(obj).forEach(([key, value]) => {
  137. const currentKey = prev ? `${prev}.${key}` : key
  138. if (isObject(value)) {
  139. digKeys(currentKey, value)
  140. } else {
  141. res[currentKey] = value
  142. }
  143. })
  144. }
  145. digKeys('', obj)
  146. return res
  147. }
  148. export default {
  149. data() {
  150. return {
  151. buildName: '',
  152. keysArr: [], //保存临时的文件key
  153. buildDialogVis: false,
  154. form: {},
  155. dialogImageUrl: '',
  156. dialogVisible: false,
  157. all: true,
  158. rules: {
  159. "BuildLocalID": [
  160. {"required": true, "message": "请输入建筑本地编码", "trigger": "blur"}
  161. ],
  162. "BuildLocalName": [
  163. {"required": true, "message": "请输入建筑本地名称", "trigger": "blur"}
  164. ]
  165. },
  166. buildData: {},
  167. dialog:{
  168. uploadFiles:false
  169. }
  170. }
  171. },
  172. components: {uploadFiles},
  173. props: ['buildTitle', 'buildMessage', 'currentBuild'],
  174. computed: {},
  175. mounted() {
  176. },
  177. methods: {
  178. showDialog(data) {
  179. this.buildData = data || {};
  180. this.buildData = flattenKeys(this.buildData)
  181. this.timeoutSetVal()
  182. this.buildDialogVis = true
  183. },
  184. timeoutSetVal() {
  185. let that = this
  186. setTimeout(() => {
  187. if (that.form) {
  188. that.form = that.buildData
  189. } else {
  190. this.timeoutSetVal()
  191. }
  192. })
  193. },
  194. closeDialog() {
  195. this.buildDialogVis = false
  196. },
  197. submitForm(formName) {
  198. this.$refs[formName].validate((valid) => {
  199. if (valid) {
  200. this.$emit('handleBuild', this.form)
  201. } else {
  202. return false;
  203. }
  204. });
  205. },
  206. changeItem(val) {
  207. console.log(val,'======')
  208. }
  209. //上传文件弹窗触发事件
  210. // fileChange(keys) {
  211. // this.setDataToMain(keys, this.messKey, this.row);
  212. // },
  213. // handleRemove(file, fileList) {
  214. // console.log(file, fileList);
  215. // },
  216. // handlePictureCardPreview(file) {
  217. // this.dialogImageUrl = file.url;
  218. // this.dialogVisible = true;
  219. // }
  220. }
  221. }
  222. </script>
  223. <style lang="less" scoped>
  224. #messageDialog {
  225. /deep/ .el-date-editor.el-input, .el-date-editor.el-input__inner, /deep/ .el-select {
  226. width: 200px;
  227. }
  228. /deep/ .FloorTypeSelect .el-form-item__content {
  229. width: 200px;
  230. }
  231. /deep/ .el-dialog__body {
  232. height: 420px;
  233. overflow: auto;
  234. }
  235. .upload-file {
  236. width: 100%;
  237. display: block;
  238. }
  239. }
  240. </style>