form.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view class="page">
  3. <view class="content">
  4. <view class="head">
  5. <span class="title">写日志</span>
  6. </view>
  7. <view class="forms">
  8. <view class="title2">张三的金科环境项目日志</view>
  9. <view class="title-sub">日志详情</view>
  10. <uni-forms
  11. :modelValue="formData"
  12. label-position="left"
  13. class="form"
  14. ref="form"
  15. :rules="rules"
  16. >
  17. <view class="box" v-for="item in formData" :key="item.key">
  18. <view
  19. v-show="formData.length > 1"
  20. class="btn-remove"
  21. @click="removeFormData(item.key)"
  22. >-</view
  23. >
  24. <uni-forms-item
  25. required
  26. label="项目名称"
  27. name="project_name"
  28. class="formItem"
  29. v-if="!project_id"
  30. >
  31. <picker
  32. @change="selectProjectList"
  33. :range="projectList"
  34. :range-key="'name'"
  35. >
  36. <!-- <view class="select" v-if="formData.industry">
  37. {{ `${formData.industry.name}(${formData.industry.code})` }}
  38. </view> -->
  39. <view class="selectPlaceholder">请选择项目</view>
  40. </picker>
  41. </uni-forms-item>
  42. <uni-forms-item
  43. required
  44. label="日志概述"
  45. name="project_name"
  46. class="formItem"
  47. >
  48. <input
  49. v-model="formData.project_name"
  50. class="input"
  51. placeholder="请输入日志概述"
  52. />
  53. </uni-forms-item>
  54. <uni-forms-item
  55. required
  56. label="日志详情"
  57. name="project_name"
  58. class="formItem"
  59. >
  60. <textarea class="textarea" placeholder="请输入日志详情" />
  61. </uni-forms-item>
  62. </view>
  63. </uni-forms>
  64. <view class="btn-add" @click="addFormData">+ 新增</view>
  65. </view>
  66. <view class="button">提 交</view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. export default {
  72. data() {
  73. return {
  74. scrollTop: 0,
  75. projectList: [],
  76. project_id: '',
  77. formData: [
  78. {
  79. key: +new Date(),
  80. project_name: "",
  81. },
  82. ],
  83. rules: {
  84. project_name: {
  85. rules: [
  86. {
  87. required: true,
  88. errorMessage: "请选择项目名称",
  89. },
  90. ],
  91. },
  92. },
  93. };
  94. },
  95. onLoad(options) {
  96. this.project_id = options.project_id;
  97. },
  98. methods: {
  99. selectProjectList(e) {
  100. // this.formData.version = e.target.value + 1;
  101. // this.formData.code.version = this.formData.version + "";
  102. // this.binddata("version", e.target.value);
  103. },
  104. addFormData() {
  105. this.formData.push({
  106. key: +new Date(),
  107. project_name: "",
  108. });
  109. },
  110. removeFormData(key) {
  111. let index = this.formData.findIndex((item) => item.key == key);
  112. this.formData.splice(index, 1);
  113. },
  114. },
  115. };
  116. </script>
  117. <style lang="less" scoped>
  118. .head {
  119. width: calc(100% - 60rpx);
  120. padding: 40rpx;
  121. position: fixed;
  122. background: url("~@/static/app-plus/menu-title-bg.png") no-repeat center;
  123. background-size: 100% 100%;
  124. background-color: #fff;
  125. display: flex;
  126. justify-content: space-between;
  127. align-items: center;
  128. z-index: 1;
  129. .title {
  130. font: 18px bold;
  131. color: #fff;
  132. }
  133. }
  134. .forms {
  135. padding: 40rpx 34rpx;
  136. padding-top: 168rpx;
  137. .title2 {
  138. font-size: 28rpx;
  139. font-weight: 400;
  140. color: #4a90e2;
  141. line-height: 40rpx;
  142. padding-bottom: 18rpx;
  143. border-bottom: 1px solid #e8e8e8;
  144. }
  145. .title-sub {
  146. font-size: 28rpx;
  147. font-weight: 400;
  148. color: #4a4a4a;
  149. line-height: 40rpx;
  150. margin-top: 20rpx;
  151. margin-bottom: 20rpx;
  152. }
  153. .formItem {
  154. }
  155. .input,
  156. .textarea,
  157. .selectPlaceholder {
  158. font-size: 28rpx;
  159. padding-left: 24rpx;
  160. border: 1rpx solid #c0c0c0;
  161. }
  162. .input,
  163. .selectPlaceholder {
  164. line-height: 72rpx;
  165. height: 72rpx;
  166. }
  167. .textarea {
  168. padding-top: 10rpx;
  169. width: 400rpx;
  170. height: 200rpx;
  171. }
  172. }
  173. .form {
  174. margin: 0 20px;
  175. }
  176. .button {
  177. position: fixed;
  178. bottom: 0;
  179. left: 0;
  180. width: 100%;
  181. height: 100rpx;
  182. background: url("~@/static/btn-bg.png") no-repeat center;
  183. background-size: 100% 100%;
  184. font-size: 38rpx;
  185. font-weight: 500;
  186. color: #ffffff;
  187. line-height: 100rpx;
  188. text-align: center;
  189. }
  190. .btn-add {
  191. width: 140rpx;
  192. height: 50rpx;
  193. border: 1rpx solid #329bfe;
  194. color: #329bfe;
  195. display: flex;
  196. justify-content: center;
  197. align-items: center;
  198. margin-left: 48rpx;
  199. }
  200. .box {
  201. position: relative;
  202. }
  203. .btn-remove {
  204. position: absolute;
  205. right: -10px;
  206. top: -12px;
  207. width: 12px;
  208. height: 12px;
  209. background: #f54444;
  210. border-radius: 50%;
  211. line-height: 20rpx;
  212. text-align: center;
  213. color: #fff;
  214. font-weight: bold;
  215. }
  216. .forms {
  217. padding-bottom: 140rpx;
  218. }
  219. </style>