addCode.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="">
  3. <form @submit="addCode">
  4. <view class="body">
  5. 名称:<input class="input" placeholder="如:炉头" name="name" :value=name />
  6. </view>
  7. <view class="body">
  8. 编码:<input class="input" name="code" />
  9. </view>
  10. <view class="title">配件</view>
  11. <view class="body2">
  12. <input class="input" name="flagCode1" />
  13. </view>
  14. <view class="body2">
  15. <input class="input" name="flagCode2" />
  16. </view>
  17. <view class="body2">
  18. <input class="input" name="flagCode3" />
  19. </view>
  20. <view class="body2">
  21. <input class="input" name="flagCode4" />
  22. </view>
  23. <view class="body2">
  24. <input class="input" name="flagCode5" />
  25. </view>
  26. <view class="body2">
  27. <input class="input" name="flagCode6" />
  28. </view>
  29. <view class="body2">
  30. <input class="input" name="flagCode7" />
  31. </view>
  32. <view class="body2">
  33. <input class="input" name="flagCode8" />
  34. </view>
  35. <view class="body2">
  36. <input class="input" name="flagCode9" />
  37. </view>
  38. <view class="body2">
  39. <input class="input" name="flagCode10" />
  40. </view>
  41. <view class="body2">
  42. <input class="input" name="flagCode11" />
  43. </view>
  44. <view class="body2">
  45. <input class="input" name="flagCode12" />
  46. </view>
  47. <view class="body2">
  48. <input class="input" name="flagCode13" />
  49. </view>
  50. <view class="body2">
  51. <input class="input" name="flagCode14" />
  52. </view>
  53. <view class="body2">
  54. <input class="input" name="flagCode15" />
  55. </view>
  56. <view class="body">
  57. 改动内容:<textarea class="input-two" name="remark" />
  58. </view>
  59. <view class="">
  60. <button type="primary" formType="submit" class="button">
  61. <p class="p">提交</p>
  62. </button>
  63. </view>
  64. </form>
  65. </view>
  66. </template>
  67. <script>
  68. import {
  69. mapState,
  70. mapActions,
  71. mapMutations
  72. } from 'vuex'
  73. export default {
  74. data() {
  75. return {
  76. name: '',
  77. username: "",
  78. parm: {
  79. name: null,
  80. id: null
  81. },
  82. };
  83. },
  84. onPullDownRefresh() {},
  85. onShow() {
  86. var token = uni.getStorageSync("token");
  87. if (token.length > 1) {
  88. var name = uni.getStorageSync("name");
  89. } else {
  90. uni.reLaunch({
  91. url: '../Login/Login',
  92. });
  93. }
  94. },
  95. onLoad() {
  96. },
  97. methods: {
  98. // ...mapActions('chart', ['updata']),
  99. addCode(event) {
  100. const {
  101. value: code
  102. } = event.detail;
  103. //首先获取到表单提交上来的值,此时input的name是不同的,为a0,a1,a2,a3...
  104. var eValue = event.detail.value;
  105. let strMap = new Map();
  106. for (let k of Object.keys(eValue)) {
  107. strMap.set(k, eValue[k]);
  108. }
  109. //将value对象转为map
  110. var mapValue = strMap;
  111. //获取list,此处的目的为获取list的长度,并通过循环拼接需要取出的names列表
  112. var aList = [];
  113. for(var i = 1;i <=15;i++){
  114. var ai = "flagCode" + i;
  115. var a = mapValue.get(ai);
  116. if(a!=""&&a!=null){
  117. aList.push(a);
  118. }
  119. }
  120. code.flagCode = aList.toString();
  121. // console.log(aList);
  122. this.$store.dispatch('addCode', code)
  123. .then(_ => {
  124. uni.showModal({
  125. title: '提示',
  126. content: _.message,
  127. });
  128. });
  129. },
  130. }
  131. }
  132. </script>
  133. <style>
  134. .body {
  135. background-color: #FFFFFF;
  136. padding: 20upx 25upx 20upx 20upx;
  137. display: flex;
  138. flex-direction: row;
  139. justify-content: flex-start;
  140. }
  141. .body2 {
  142. background-color: #FFFFFF;
  143. padding: 20upx 25upx 20upx 20upx;
  144. padding-left: 100upx;
  145. display: flex;
  146. flex-direction: row;
  147. justify-content: flex-start;
  148. }
  149. .input {
  150. /* padding: 10upx 20upx 10upx 0upx; */
  151. padding-left: 20upx;
  152. padding-top: 0upx;
  153. background-color: #FFFFFF;
  154. width: 500upx;
  155. height: 50upx;
  156. box-shadow: 0upx 0upx 20upx #D3D3D3;
  157. border-radius: 5upx;
  158. }
  159. .input-two{
  160. padding-left: 20upx;
  161. width: 450upx;
  162. box-shadow: 0upx 0upx 20upx #D3D3D3;
  163. border-radius: 5upx;
  164. }
  165. .button {
  166. margin: auto;
  167. width: 60%;
  168. height: 100upx;
  169. }
  170. .p {
  171. /* #ifdef H5 */
  172. top: -13%;
  173. /* #endif */
  174. width: 80upx;
  175. height: 60upx;
  176. font-size: 40upx;
  177. padding-top: 6upx;
  178. /* #ifndef H5 */
  179. padding-top: 10upx;
  180. /* #endif */
  181. position: absolute;
  182. /* 水平居中 */
  183. left: 50%;
  184. -webkit-transform: translateX(-50%);
  185. transform: translateX(-50%);
  186. }
  187. .title {
  188. padding-left: 20upx;
  189. font-size: 35upx;
  190. }
  191. </style>