CheckCard.vue 8.1 KB

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