CheckCard.vue 7.6 KB

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