CheckCard.vue 9.0 KB

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