CheckCard.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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="请选择"
  38. :localdata="statusList" :clear-icon="false">
  39. </uni-data-picker>
  40. </view>
  41. </text>
  42. </view>
  43. <view class="card-cell">
  44. <text class="label">结果</text>
  45. <view class="cell-content">
  46. <textarea v-if="type !== 'view'" placeholder="请输入" v-model="item.result"
  47. />
  48. <view class="result-text" v-else>{{ item.result }}</view>
  49. <view class="radio-wrapper" v-if="type !== 'view'">
  50. <!-- <div
  51. v-for="(it, ind) in statusList"
  52. :key="ind"
  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.isNormal"
  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.isNormal === 0 ? 'text-danger' : ''"
  76. v-else
  77. style="min-height: 1em"
  78. >
  79. {{ ['异常', '正常'][item.isNormal] }}
  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. <!-- <u-album :urls="photoList" :rowCount="3" @delete="handleDelete" :maxCount="9" :singleSize="180"
  96. :multipleSize="180"></u-album> -->
  97. </view>
  98. </view>
  99. </view>
  100. <u-toast ref="uToast"></u-toast>
  101. </view>
  102. </template>
  103. <script>
  104. import PreviewPhoto from './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. changeStatus(item, it) {
  156. item.status = it.status
  157. },
  158. // handleDelete(e, i) {
  159. // console.log(e, 'eeeee');
  160. // console.log(i, 'iiiiiiiiiiii')
  161. // },
  162. // 图片删除
  163. imagedelete(index) {
  164. this.item.photoList.splice(index, 1);
  165. },
  166. // *** 新增拍照功能
  167. chooseImage() {
  168. const _this = this
  169. if (_this.photoList.length >= 9) {
  170. _this.$refs.uToast.show({
  171. type: "warning",
  172. message: "最多上传9张照片",
  173. })
  174. return
  175. }
  176. uni.chooseImage({
  177. count: 9, //默认9
  178. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  179. sourceType: ['camera'], //从相册选择
  180. success: function(res) {
  181. uni.showLoading({
  182. title: '加载中'
  183. })
  184. _this.uploadFile(res.tempFilePaths).then(res => {
  185. res.forEach(item => {
  186. let fileNames = item.storePath.split('/')
  187. let url = _this.apiUrl +
  188. '/main/file/getFile?objectName=' + item.storePath +
  189. '&fullfilename=' + fileNames[fileNames.length -
  190. 1]
  191. console.log(_this.item, 'url ---')
  192. if (!_this.item.photoList || _this.item.photoList?.length ==
  193. 0) {
  194. _this.$set(_this.item, 'photoList', [url])
  195. } else {
  196. // 不能存储超过 9 张
  197. if (_this.item.photoList.length < 9) {
  198. _this.item.photoList.push(url);
  199. }
  200. }
  201. // _this.imgs.push(url)
  202. })
  203. uni.hideLoading()
  204. })
  205. }
  206. });
  207. },
  208. uploadFile(list) {
  209. let PromiseAll = []
  210. const apiUrl = this.apiUrl
  211. const token = uni.getStorageSync("token"); //取存本地的token
  212. list.forEach(item => {
  213. PromiseAll.push(
  214. new Promise((resolve, reject) => {
  215. uni.uploadFile({
  216. url: apiUrl + '/main/file/upload',
  217. filePath: item,
  218. name: 'multiPartFile',
  219. header: {
  220. authorization: token
  221. },
  222. success: (uploadFileRes) => {
  223. let data = JSON.parse(uploadFileRes.data)
  224. resolve(data.data)
  225. }
  226. });
  227. }),
  228. )
  229. })
  230. return Promise.all(PromiseAll)
  231. },
  232. }
  233. }
  234. </script>
  235. <style lang="scss" scoped>
  236. $border-color: #f2f2f2;
  237. .kd-check-card {
  238. font-size: 28rpx;
  239. border: 1rpx solid $border-color;
  240. .label {
  241. display: inline-block;
  242. width: 80rpx;
  243. text-align: center;
  244. border-right: 1px solid $border-color;
  245. justify-content: center;
  246. .mark {
  247. width: 80rpx;
  248. height: 4rpx;
  249. display: inline-block;
  250. }
  251. }
  252. .title {
  253. line-height: 72rpx;
  254. font-weight: bold;
  255. background-color: #f2f2f2;
  256. }
  257. .card-cell {
  258. min-height: 72rpx;
  259. display: flex;
  260. align-items: stretch;
  261. border: 1px solid $border-color;
  262. text {
  263. display: flex;
  264. align-items: center;
  265. }
  266. }
  267. .cell-content {
  268. flex: 1;
  269. .content-status {
  270. width: 100%;
  271. height: 50rpx;
  272. line-height: 50rpx;
  273. text-indent: 10rpx;
  274. border-bottom: 1rpx solid #f2f2f2;
  275. }
  276. }
  277. .radio-wrapper {
  278. padding: 10rpx 20rpx;
  279. border-bottom: 1px solid $border-color;
  280. margin-left: -8rpx;
  281. }
  282. /deep/uni-textarea {
  283. width: 100%;
  284. box-sizing: border-box;
  285. }
  286. .result-text {
  287. min-height: 100rpx;
  288. padding: 10rpx;
  289. }
  290. .cell-content {
  291. padding-left: 8rpx;
  292. }
  293. .radio-wrapper {
  294. display: flex;
  295. align-items: center;
  296. justify-content: space-around;
  297. }
  298. .wrapper-box {
  299. width: 45%;
  300. height: 80rpx;
  301. line-height: 80rpx;
  302. text-align: center;
  303. border: 1rpx solid #000;
  304. color: #000;
  305. border-radius: 15rpx;
  306. }
  307. .photo_info {
  308. width: 100%;
  309. padding: 6px 12rpx;
  310. // display: flex;
  311. // align-items: center;
  312. .btn_box {
  313. width: 100%;
  314. }
  315. .photo_btn {
  316. // margin-left: ;
  317. background-color: #157a2c;
  318. width: 140rpx;
  319. height: 60rpx;
  320. text-align: center;
  321. line-height: 60rpx;
  322. font-size: 24rpx;
  323. color: #fff;
  324. text-align: center;
  325. border-radius: 8rpx;
  326. margin-bottom: 12rpx;
  327. display: inline-block;
  328. }
  329. }
  330. /deep/.u-album__row__wrapper {
  331. uni-image {
  332. width: 180rpx !important;
  333. height: 180rpx !important;
  334. }
  335. }
  336. }
  337. </style>