CheckCard.vue 8.6 KB

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