CheckCard.vue 8.0 KB

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