CheckCard.vue 8.1 KB

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