repairRecord.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <view class="container">
  3. <view class="title">维修日期</view>
  4. <uni-datetime-picker placeholder="请选择日期" type="date" v-model="single" />
  5. <view class="title">维修内容</view>
  6. <view class="textarea">
  7. <textarea placeholder-style="color:#CCCCCC" placeholder="请输入维修内容"></textarea>
  8. </view>
  9. <view class="title">维修结果</view>
  10. <!-- 录音区域 -->
  11. <view class="voice">
  12. <view class="voice_box">
  13. <img src="../../static/images/repairsImg/voice.png" />
  14. </view>
  15. 点击录音
  16. </view>
  17. <view class="title">关联耗材</view>
  18. <!-- 每一个耗材盒子区域 -->
  19. <view class="detail_box">
  20. <view class="detail_box_item">
  21. <view class="item_key">耗材名称</view>
  22. <view class="item_value">螺丝钉</view>
  23. </view>
  24. <view class="detail_box_item">
  25. <view class="item_key">耗材数量</view>
  26. <view class="item_value">
  27. <uni-number-box v-model="count" :min="0" @change="bindChange"></uni-number-box>
  28. </view>
  29. </view>
  30. <view class="detail_box_item">
  31. <view class="item_key">耗材单价</view>
  32. <view class="item_value">0.5</view>
  33. </view>
  34. </view>
  35. <!-- 添加耗材区域 -->
  36. <view class="add" @click="handleAdd">
  37. <text>+</text>
  38. 添加耗材
  39. </view>
  40. <!-- 合计费用区域 -->
  41. <view class="total">
  42. <view>合计费用</view>
  43. <view>10元</view>
  44. </view>
  45. <view class="title">维修师傅</view>
  46. <view class="box">
  47. <img src="../../static/images/repairsImg/people.png" />
  48. 张三
  49. </view>
  50. <view class="title">手机</view>
  51. <view class="box">
  52. <img src="../../static/images/repairsImg/phone2.png" />
  53. 13659854589
  54. </view>
  55. <view class="title">现场拍照</view>
  56. <uni-file-picker
  57. ref="filePicker"
  58. limit="3"
  59. v-model="imgList"
  60. fileMediatype="image"
  61. :image-styles="imageStyles"
  62. mode="grid"
  63. @select="select"
  64. @delete="handleDelete"
  65. ></uni-file-picker>
  66. <view class="btn">确认提交</view>
  67. <!-- 用于图片压缩的canvas画布 -->
  68. <canvas
  69. :style="{
  70. width: cw + 'px',
  71. height: cw + 'px',
  72. position: 'absolute',
  73. zIndex: -1,
  74. left: '-10000rpx',
  75. top: '-10000rpx'
  76. }"
  77. canvas-id="zipCanvas"
  78. ></canvas>
  79. <!--画布结束-->
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. single: '',
  87. count: 6,
  88. // 显示的图片数据
  89. imgList: [],
  90. // 上传的图片数据
  91. subImgList: [],
  92. // 图片上传框的样式
  93. imageStyles: {
  94. width: 60,
  95. height: 60,
  96. border: {
  97. color: '#ccc',
  98. width: 1,
  99. style: 'dashed',
  100. radius: '9px'
  101. }
  102. },
  103. //画板边长默认是屏幕宽度,正方形画布
  104. cw: uni.getSystemInfoSync().windowWidth
  105. }
  106. },
  107. methods: {
  108. bindChange() {},
  109. handleAdd() {
  110. uni.navigateTo({
  111. url: '/pagesRepairs/addGoods/addGoods'
  112. })
  113. },
  114. // 选择图片回调
  115. select(e) {
  116. console.log(e)
  117. e.tempFiles.forEach((item) => {
  118. //这里的id和页面中写的html代码的canvas的id要一致
  119. let canvasId = 'zipCanvas'
  120. //原图的路径
  121. let imagePath = item.path
  122. //大小限制1024kb
  123. let limitSize = 1024
  124. //初始绘画区域是画布自身的宽度也就是屏幕宽度
  125. let drawWidth = uni.getSystemInfoSync().windowWidth
  126. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, (resPath) => {
  127. uni.showLoading({
  128. title: '上传中'
  129. })
  130. uni.uploadFile({
  131. url: `https://jiangxih3cpartner.com/reporting/file/fileUpDown`,
  132. filePath: resPath,
  133. name: 'file',
  134. success: (uploadFileRes) => {
  135. subImgList.value.push(JSON.parse(uploadFileRes.data).data.join())
  136. imgList.value.push({
  137. url: item.path,
  138. name: ''
  139. })
  140. uni.hideLoading()
  141. },
  142. fail: () => {
  143. uni.showToast({
  144. title: '上传失败',
  145. icon: 'error'
  146. })
  147. }
  148. })
  149. })
  150. })
  151. },
  152. handleDelete(e) {
  153. // console.log(e);
  154. const num = imgList.value.findIndex((v) => v.url === e.tempFilePath)
  155. subImgList.value.splice(num, 1)
  156. imgList.value.splice(num, 1)
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang="scss" scoped>
  162. .container {
  163. box-sizing: border-box;
  164. padding: 0 30rpx;
  165. overflow-y: auto;
  166. .title {
  167. display: flex;
  168. align-items: center;
  169. height: 107rpx;
  170. font-size: 36rpx;
  171. font-weight: bold;
  172. }
  173. .textarea {
  174. height: 310rpx;
  175. border-radius: 10rpx;
  176. border: 1rpx solid #cccccc;
  177. textarea {
  178. box-sizing: border-box;
  179. padding: 25rpx 35rpx;
  180. width: 100%;
  181. font-size: 32rpx;
  182. }
  183. }
  184. .voice {
  185. display: flex;
  186. align-items: center;
  187. height: 94rpx;
  188. font-size: 32rpx;
  189. color: #cccccc;
  190. border-radius: 10rpx;
  191. border: 1rpx solid #cccccc;
  192. .voice_box {
  193. display: flex;
  194. justify-content: center;
  195. align-items: center;
  196. margin: 0 38rpx 0 33rpx;
  197. width: 101rpx;
  198. height: 47rpx;
  199. border-radius: 33rpx;
  200. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  201. img {
  202. width: 33rpx;
  203. height: 33rpx;
  204. }
  205. }
  206. }
  207. .detail_box {
  208. box-sizing: border-box;
  209. margin-bottom: 46rpx;
  210. padding: 5rpx 30rpx 0;
  211. width: 690rpx;
  212. height: 284rpx;
  213. border-radius: 9rpx;
  214. box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);
  215. .detail_box_item {
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. height: 92rpx;
  220. font-size: 32rpx;
  221. border-bottom: 1rpx solid #e5e5e5;
  222. .item_key {
  223. width: 150rpx;
  224. color: #808080;
  225. }
  226. .item_value {
  227. font-weight: bold;
  228. }
  229. }
  230. }
  231. .add {
  232. display: flex;
  233. justify-content: center;
  234. align-items: center;
  235. width: 690rpx;
  236. height: 90rpx;
  237. color: #6fb6b8;
  238. font-size: 32rpx;
  239. border-radius: 9rpx;
  240. background-color: #ebf2f2;
  241. text {
  242. margin-right: 10rpx;
  243. font-size: 48rpx;
  244. }
  245. }
  246. .total {
  247. display: flex;
  248. justify-content: space-between;
  249. align-items: center;
  250. margin: auto;
  251. width: 622rpx;
  252. height: 100rpx;
  253. font-size: 32rpx;
  254. font-weight: bold;
  255. border-bottom: 1rpx solid #e5e5e5;
  256. }
  257. .box {
  258. display: flex;
  259. align-items: center;
  260. height: 94rpx;
  261. font-size: 32rpx;
  262. border-radius: 10rpx;
  263. border: 1rpx solid #cccccc;
  264. img {
  265. margin: 0 14rpx 0 30rpx;
  266. width: 40rpx;
  267. height: 40rpx;
  268. }
  269. }
  270. .btn {
  271. display: flex;
  272. justify-content: center;
  273. align-items: center;
  274. margin: 65rpx 0 60rpx;
  275. height: 100rpx;
  276. color: #fff;
  277. font-size: 32rpx;
  278. border-radius: 12rpx;
  279. background-color: #6fb6b8;
  280. }
  281. }
  282. </style>