CheckCard.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view class="kd-check-card">
  3. <view class="title">
  4. <text class="label">{{ index + 1 }}</text>
  5. <text>{{ item.name }}</text>
  6. </view>
  7. <view class="card-cell">
  8. <text class="label">内容</text>
  9. <text class="cell-content">{{ item.content }}</text>
  10. </view>
  11. <view class="card-cell">
  12. <text class="label">标准</text>
  13. <text class="cell-content">{{ item.norm }}</text>
  14. </view>
  15. <!-- <view class="card-cell">
  16. <text class="label">工具</text>
  17. <view class="cell-content" v-if="item.operationGuide && item.operationGuide.toolList.length > 0">
  18. <view v-for="(item, index) in item.operationGuide.toolList">{{ index + 1 }}、{{ item.categoryLevelName }}</view>
  19. </view>
  20. <view class="cell-content" v-else>无</view>
  21. </view>
  22. <view class="card-cell">
  23. <text class="label">指导</text>
  24. <view class="cell-content" v-if="item.operationGuide && item.operationGuide.procedureList.length > 0">
  25. <view v-for="(item, index) in item.operationGuide.procedureList">{{ index + 1 }}、{{ item.content }}</view>
  26. </view>
  27. <view class="cell-content" v-else>无</view>
  28. </view> -->
  29. <view class="card-cell">
  30. <text class="label">结果</text>
  31. <view class="cell-content">
  32. <view class="content-status" v-if="type == 'view'">
  33. <!-- {{ item.executeStatus?'正常':'异常' }} -->
  34. <div v-if="item.status == 0" style="color: green">正常</div>
  35. <div v-else-if="item.status == -1" style="color: red">异常</div>
  36. </view>
  37. <textarea v-if="type !== 'view'" placeholder="请输入" v-model="item.result" @input="inputChange($event, item)" />
  38. <view class="result-text" v-else>{{ item.result }}</view>
  39. <view class="radio-wrapper">
  40. <!-- <div
  41. v-for="(it, ind) in statusList"
  42. :key="ind"
  43. v-if="type !== 'view'"
  44. class="wrapper-box"
  45. @click="changeStatus(item, it)"
  46. :style="item.status == it.status && item.status == -1 ? 'color:red;border: 1rpx solid red' : item.status == it.status && item.status == 0 ? 'color:green;border: 1rpx solid green' : ''">
  47. {{ it.label }}
  48. </div> -->
  49. <!-- <u-radio-group
  50. v-model="item.executeStatus"
  51. placement="row"
  52. v-if="type !== 'view'"
  53. :size="28"
  54. >
  55. <u-radio
  56. :customStyle="{ marginRight: '20px' }"
  57. :labelSize="30"
  58. label="正常"
  59. :name="1"
  60. >
  61. </u-radio>
  62. <u-radio :customStyle="{}" :labelSize="30" label="异常" :name="0">
  63. </u-radio>
  64. </u-radio-group> -->
  65. <!-- <view
  66. :class="item.executeStatus === 0 ? 'text-danger' : ''"
  67. v-else
  68. style="min-height: 1em"
  69. >
  70. {{ ['异常', '正常'][item.executeStatus] }}
  71. </view> -->
  72. </view>
  73. </view>
  74. </view>
  75. <!-- 新增拍照 *** -->
  76. <view class="card-cell">
  77. <text class="label">
  78. <span class="mark"></span>
  79. </text>
  80. <view class="photo_info">
  81. <view class="btn_box" v-if="type != 'view'">
  82. <text class="photo_btn" @click="chooseImage">拍照</text>
  83. </view>
  84. <view class="photo_list">
  85. <PreviewPhoto :type="type" @imagedelete="imagedelete" :imageList="photoList" />
  86. </view>
  87. </view>
  88. </view>
  89. <u-toast ref="uToast"></u-toast>
  90. </view>
  91. </template>
  92. <script>
  93. import PreviewPhoto from '@/pages/maintenance/check/components/PreviewPhoto.vue'
  94. export default {
  95. components:{ PreviewPhoto },
  96. props: {
  97. item: {
  98. type: Object,
  99. default: () => ({})
  100. },
  101. index: Number,
  102. type: {
  103. type: String,
  104. default: 'edit'
  105. }
  106. },
  107. data() {
  108. return {
  109. statusList: [
  110. { label: '正常', status: 0 },
  111. { label: '异常', status: -1 }
  112. ]
  113. }
  114. },
  115. // *** 新增
  116. computed: {
  117. photoList() {
  118. if (!this.item.photoList) return []
  119. return this.item.photoList
  120. }
  121. },
  122. methods: {
  123. inputChange(obj, item) {
  124. if (obj.target.value.length > 0) {
  125. item.status = -1
  126. } else {
  127. item.status = 0
  128. }
  129. },
  130. changeStatus(item, it) {
  131. item.status = it.status
  132. },
  133. // *** 新增拍照功能
  134. chooseImage() {
  135. const _this = this
  136. if(_this.photoList.length >= 9){
  137. _this.$refs.uToast.show({
  138. type: "warning",
  139. message: "最多上传9张照片",
  140. })
  141. return
  142. }
  143. uni.chooseImage({
  144. count: 9, //默认9
  145. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  146. sourceType: ['camera'], //从相册选择
  147. success: function(res) {
  148. uni.showLoading({
  149. title: '加载中'
  150. })
  151. _this.uploadFile(res.tempFilePaths).then(res => {
  152. res.forEach(item => {
  153. let fileNames = item.storePath.split('/')
  154. let url = _this.apiUrl +
  155. '/main/file/getFile?objectName=' + item.storePath +
  156. '&fullfilename=' + fileNames[fileNames.length -
  157. 1]
  158. console.log(_this.item, 'url ---')
  159. if (!_this.item.photoList || _this.item.photoList?.length ==
  160. 0) {
  161. _this.$set(_this.item, 'photoList', [url])
  162. } else {
  163. // 不能存储超过 9 张
  164. if(_this.item.photoList.length < 9){
  165. _this.item.photoList.push(url);
  166. }
  167. }
  168. // _this.imgs.push(url)
  169. })
  170. uni.hideLoading()
  171. })
  172. }
  173. });
  174. },
  175. uploadFile(list) {
  176. let PromiseAll = []
  177. const apiUrl = this.apiUrl
  178. const token = uni.getStorageSync("token"); //取存本地的token
  179. list.forEach(item => {
  180. PromiseAll.push(
  181. new Promise((resolve, reject) => {
  182. uni.uploadFile({
  183. url: apiUrl + '/main/file/upload',
  184. filePath: item,
  185. name: 'multiPartFile',
  186. header: {
  187. authorization: token
  188. },
  189. success: (uploadFileRes) => {
  190. let data = JSON.parse(uploadFileRes.data)
  191. resolve(data.data)
  192. }
  193. });
  194. }),
  195. )
  196. })
  197. return Promise.all(PromiseAll)
  198. },
  199. // 图片删除
  200. imagedelete(index){
  201. this.item.photoList.splice(index,1);
  202. },
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. $border-color: #f2f2f2;
  208. .kd-check-card {
  209. font-size: 28rpx;
  210. border: 1rpx solid $border-color;
  211. .label {
  212. display: inline-block;
  213. width: 80rpx;
  214. text-align: center;
  215. border-right: 1px solid $border-color;
  216. justify-content: center;
  217. }
  218. .mark{
  219. width: 80rpx;
  220. height: 4rpx;
  221. display: inline-block;
  222. }
  223. .title {
  224. line-height: 72rpx;
  225. font-weight: bold;
  226. background-color: #f2f2f2;
  227. }
  228. .card-cell {
  229. min-height: 72rpx;
  230. display: flex;
  231. align-items: stretch;
  232. border: 1px solid $border-color;
  233. text {
  234. display: flex;
  235. align-items: center;
  236. }
  237. }
  238. .cell-content {
  239. flex: 1;
  240. .content-status {
  241. width: 100%;
  242. height: 50rpx;
  243. line-height: 50rpx;
  244. text-indent: 10rpx;
  245. border-bottom: 1rpx solid #f2f2f2;
  246. }
  247. }
  248. .radio-wrapper {
  249. padding: 10rpx 20rpx;
  250. border-bottom: 1px solid $border-color;
  251. margin-left: -8rpx;
  252. }
  253. /deep/uni-textarea {
  254. width: 100%;
  255. box-sizing: border-box;
  256. }
  257. .result-text {
  258. min-height: 100rpx;
  259. padding: 10rpx;
  260. }
  261. .cell-content {
  262. padding-left: 8rpx;
  263. }
  264. .radio-wrapper {
  265. display: flex;
  266. align-items: center;
  267. justify-content: space-around;
  268. }
  269. .wrapper-box {
  270. width: 45%;
  271. height: 80rpx;
  272. line-height: 80rpx;
  273. text-align: center;
  274. border: 1rpx solid #000;
  275. color: #000;
  276. border-radius: 15rpx;
  277. }
  278. }
  279. .photo_info {
  280. width: 100%;
  281. padding: 6px 12rpx;
  282. .btn_box{
  283. width: 100%;
  284. }
  285. .photo_btn {
  286. background-color: #157a2c;
  287. width: 140rpx;
  288. height: 60rpx;
  289. line-height: 60rpx;
  290. font-size: 24rpx;
  291. color: #fff;
  292. text-align: center;
  293. border-radius: 8rpx;
  294. margin-bottom: 12rpx;
  295. display: inline-block !important;
  296. }
  297. }
  298. </style>