build.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <section>
  3. <div v-if="buildType == 'create'">
  4. <el-form ref="copyData" :model="copyData" label-width="120px" style="border: 1px solid #ccc;padding:3px;padding-top:30px;">
  5. <el-form-item label="本地名称"
  6. :rules="{ required: true, message: '本地名称不能为空', trigger: 'blur' }">
  7. <el-input v-model="copyData.infos.BuildLocalName"></el-input>
  8. </el-form-item>
  9. <el-form-item label="本地编码"
  10. :rules="{ required: true, message: '本地编码不能为空', trigger: 'blur' }">
  11. <el-input v-model="copyData.infos.BuildLocalID"></el-input>
  12. </el-form-item>
  13. <el-form-item label="建筑年代">
  14. <el-date-picker
  15. style="width:100%;"
  16. v-model="copyData.infos.BuildAge"
  17. type="date"
  18. value-format="yyyy-MM-dd"
  19. placeholder="选择日期">
  20. </el-date-picker>
  21. </el-form-item>
  22. <el-form-item label="建筑功能类型">
  23. <el-cascader
  24. :options="arr"
  25. v-model="copyData.infos.BuildFuncType"
  26. :props="props"
  27. ></el-cascader>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button type="primary" @click="onSubmit">立即创建</el-button>
  31. <el-button @click="noCreate">取消</el-button>
  32. </el-form-item>
  33. </el-form>
  34. </div>
  35. <div class="build-border" v-else>
  36. <!-- 建筑基本信息 -->
  37. <div v-show="!messBuild">
  38. <form-input :value="copyData.infos.BuildLocalName" @change="changed" :keys="'BuildLocalName'" :label="'本地名称'" :isRule="false"></form-input>
  39. <form-input :value="copyData.infos.BuildLocalID" @change="changed" :keys="'BuildLocalID'" :label="'本地编码'" :isRule="false"></form-input>
  40. <form-input type="year" :value="copyData.infos.BuildAge" @change="changed" :keys="'BuildAge'" :label="'建筑年代'" :isRule="false"></form-input>
  41. <form-input type="cascader" :typeArr="arr" :value="copyData.infos.BuildFuncType" @change="changed" :keys="'BuildFuncType'" :label="'建筑功能类型'" :isRule="false"></form-input>
  42. </div>
  43. <!-- 建筑详情 -->
  44. <div v-show="messBuild">
  45. <!-- 一级标签 -->
  46. <div v-for="item in buildMess" v-if="item.firstTag != '能耗信息' && item.firstTag != '建筑文档'">
  47. <h3 class="first-tag">{{item.firstTag}}</h3>
  48. <div v-for="i in item.details">
  49. <h4 class="second-tag">{{i.secondTag}}</h4>
  50. <template v-for="detail in i.details">
  51. <form-input v-if="isShow(detail.inputMode)" :width="170" :type="detail.inputMode" :typeArr="detail.dataSource" :value="copyData.infos[detail.infoPointCode]" :unit="detail.unit" @change="changed" :keys="detail.infoPointCode" :label="detail.infoPointName" :isRule="false"></form-input>
  52. </template>
  53. </div>
  54. </div>
  55. </div>
  56. <el-button type="text" @click="lookDetails" class="font-right">{{!messBuild ? '维护详细信息' : '收起'}}</el-button>
  57. </div>
  58. </section>
  59. </template>
  60. <script>
  61. import formInput from "@/components/market/owner/formInput";
  62. export default {
  63. name: "buildTemplete",
  64. props: {
  65. buildType: String, //create创建
  66. funcTypeArr: Array, //建筑下拉的options
  67. id: String, //项目id,当其为空时为create
  68. buildMess: Array, //建筑详情的数组label
  69. buildData: Object, //默认数据
  70. },
  71. components: {
  72. formInput
  73. },
  74. data() {
  75. return {
  76. year: "",
  77. arr: [],
  78. copyData: {
  79. infos: {
  80. BuildID: "",
  81. BuildLocalID: "",
  82. BuildLocalName: "",
  83. BuildName: "",
  84. BuildAge: "",
  85. BuildFuncType: []
  86. }
  87. },
  88. messBuild: false, // 是否显示详情
  89. props: {
  90. label: "name",
  91. value: "code",
  92. children: "content"
  93. } //修改默认数据格式
  94. };
  95. },
  96. created() {
  97. this.arr = this.toMyNeed(this.funcTypeArr);
  98. this.copyData = Object.assign({},this.buildData)
  99. },
  100. methods: {
  101. //提交
  102. onSubmit() {
  103. if(this.copyData.infos.BuildLocalID && this.copyData.infos.BuildLocalName){
  104. this.copyData.projectId = this.id
  105. let params = JSON.parse(JSON.stringify(this.copyData))
  106. let func = this.copyData.infos.BuildFuncType
  107. if(func instanceof Array){
  108. params.infos.BuildFuncType = func[func.length -1]
  109. }
  110. this.postJson("/server/business-os/proprietor/project/building/create",params,res=>{
  111. this.copyData.id = res.id
  112. this.buildData = Object.assign({},params)
  113. this.buildType ="change"
  114. this.$emit("created",params)
  115. })
  116. }else{
  117. this.$message.error("请确定输入本地编码和本地名称")
  118. }
  119. },
  120. //取消
  121. noCreate(){
  122. this.$emit("del")
  123. },
  124. //处理key值转换关系
  125. toMyNeed(arr) {
  126. return arr.map(res => {
  127. let param = {};
  128. if (res.content && res.content.length != 0) {
  129. param.content = this.toMyNeed(res.content);
  130. }
  131. param.name = res.name;
  132. param.code = res.code;
  133. return param;
  134. });
  135. },
  136. //判断是否是显示类型
  137. isShow(code) {
  138. if (
  139. code == "L" ||
  140. code == "L1" ||
  141. code == "L2" ||
  142. code == "M" ||
  143. code == "N1" ||
  144. code == "N2" ||
  145. code == "K" ||
  146. code == "F2" ||
  147. code == "G1" ||
  148. code == "G2" ||
  149. code == "G3" ||
  150. code == "G4" ||
  151. code == "H" ||
  152. code == "I" ||
  153. code == "J" ||
  154. code == "K" ||
  155. code == "E2"
  156. ) {
  157. return false
  158. }else{
  159. return true
  160. }
  161. },
  162. //formInput的修改事件
  163. changed(val, key) {
  164. this.copyData.infos[key] = val;
  165. this.postJson("/server/business-os/proprietor/project/building/update",this.copyData,res=>{
  166. })
  167. },
  168. //修改详情中的数值
  169. changDetail(val, key) {
  170. this.copyData.infos[key] = val;
  171. },
  172. //查看建筑详情,修改
  173. lookDetails(item) {
  174. this.messBuild = !this.messBuild;
  175. }
  176. },
  177. watch:{
  178. buildType:{
  179. deep: true,
  180. handler(old,newVal){
  181. this.copyData = this.buildData
  182. }
  183. }
  184. }
  185. };
  186. </script>
  187. <style lang="scss" scoped>
  188. .build-border {
  189. border: 1px solid #ccc;
  190. margin-top: 10px;
  191. padding-top: 10px;
  192. overflow: hidden;
  193. .font-right {
  194. float: right;
  195. margin-right: 30px;
  196. }
  197. }
  198. .first-tag{
  199. line-height: 40px;
  200. font-weight: 600;
  201. margin-left: 5px;
  202. }
  203. .second-tag{
  204. line-height: 40px;
  205. font-weight: 500;
  206. margin-left: 20px;
  207. color: #6BCAE2;
  208. }
  209. </style>