taskPhotoTaking.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <div class="taskPhotoTaking">
  3. <van-nav-bar class="navBar" left-arrow title="生动化陈列" @click-left="onClickLeft">
  4. <template #right v-if="formData">
  5. <span
  6. v-if="isEdit && insert == 'true' && formData.processStatus != 1"
  7. @click="onSubmit"
  8. style="
  9. color: white;
  10. background: rgb(0, 87, 186);
  11. display: block;
  12. padding: 6px 10px;
  13. border-radius: 6px;
  14. "
  15. >保存</span
  16. >
  17. </template>
  18. </van-nav-bar>
  19. <div class="content" v-if="formData">
  20. <div class="container">
  21. <van-form ref="tabstoreVal">
  22. <div v-for="(item, index) in formData.collectionItemList" :key="index">
  23. <div v-if="item.answerType == 'zp'" class="formLabel z-cell">
  24. <van-cell>
  25. <template #title>
  26. <!-- <span v-if="item.isMust == 0" class="van-f-red">*</span> -->
  27. <div class="headline">
  28. <span class="headlineIcon"></span>
  29. <span class="headlineTitle"
  30. >上传照片
  31. <span v-if="formData.sdhclPhotoNum" style="color: red">
  32. (拍全产品和道具,至少{{ formData.sdhclPhotoNum }}张)
  33. </span>
  34. </span>
  35. </div>
  36. <!-- 操作说明图片和电话 -->
  37. <taskTips
  38. v-if="item.contactPhone || item.examplePhoto"
  39. :contactPhone="item.contactPhone"
  40. :examplePhoto="item.examplePhoto">
  41. </taskTips>
  42. </template>
  43. </van-cell>
  44. <deleteUploadImgTaskPhoto
  45. ref="taskPhoto"
  46. :formData="formData"
  47. :storeGroupId="storeGroupId"
  48. :taskIds="taskIds"
  49. :visitsId="visitsId"
  50. :collectionItemId="item.collectionId"
  51. :putInCode="formData.putInCode"
  52. :photoIdentifyType="formData.photoIdentifyType"
  53. @upDataDetail="getDetaile"
  54. :pictureSource="item.pictureSource"
  55. :continuousShoot="item.continuousShoot"
  56. :insert="insert"
  57. :fileInfoList="item.fileInfoList"
  58. :objectType="objectType"></deleteUploadImgTaskPhoto>
  59. </div>
  60. </div>
  61. </van-form>
  62. </div>
  63. <div class="dataList" v-if="dataList">
  64. <div class="headline" style="margin-top: 10px">
  65. <span class="headlineIcon"></span>
  66. <span class="headlineTitle">门店参与的陈列任务要求</span>
  67. </div>
  68. <div class="dataItem" v-for="(item, index) in dataList">
  69. <div class="itemTop">
  70. <div class="itemIndex">
  71. <p style="margin: 5px 0 10px 0">
  72. {{ index + 1 }}、<span>{{ item.taskName }}</span>
  73. </p>
  74. </div>
  75. <div class="itemHtml" v-html="item.displayInstructions"></div>
  76. </div>
  77. <div class="itemBottom" v-if="insert == 'false'">
  78. <img
  79. v-if="item.taskPhotoConditionPassed == 1"
  80. @click="openDialog(item)"
  81. :src="require('@/assets/taskPhotoSu.png')" />
  82. <img
  83. v-if="item.taskPhotoConditionPassed == 0"
  84. @click="openDialog(item)"
  85. :src="require('@/assets/taskPhotoErr.png')" />
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. <el-dialog
  91. title="识别结果"
  92. :visible.sync="vanPopup"
  93. width="80%"
  94. :append-to-body="true"
  95. :close-on-click-modal="false"
  96. @close="vanPopup == false"
  97. custom-class="identifyResultdialog">
  98. <!-- 识别结果 -->
  99. <div class="identifyResult" v-if="taskPhotoRecognitionResult" style="padding: 0 10px">
  100. <div class="resultContent">
  101. <el-table
  102. :data="taskPhotoRecognitionResult"
  103. :span-method="taskObjectSpanMethod"
  104. border
  105. class="table-headermd1"
  106. style="width: 100%">
  107. <el-table-column label="" type="index" width="50px" align="center" />
  108. <el-table-column label="产品" prop="skuProductName" align="center" />
  109. <el-table-column
  110. label="识别排面数"
  111. prop="identifyTheNumberOfCards"
  112. width="70px"
  113. align="center">
  114. </el-table-column>
  115. <el-table-column label="要求" prop="conditionIdentifyNum" align="center" width="60px">
  116. <template slot-scope="scope">
  117. <span :style="{ color: scope.row.meetTheStandard == 1 ? '#07c160' : 'red' }">
  118. {{ scope.row.conditionIdentifyNum }}
  119. </span>
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. </div>
  124. </div>
  125. </el-dialog>
  126. </div>
  127. </template>
  128. <script>
  129. import { getCollectionInfosBatch, addCollectionAnswerBatch, getVisitsDetail } from '@/api/index';
  130. import taskTips from './taskTips';
  131. import deleteUploadImgTaskPhoto from '@/components/deleteUploadImgTaskPhoto';
  132. import { mapState } from 'vuex';
  133. export default {
  134. name: 'abnortaskPhotoTakingmalVisit',
  135. components: { taskTips, deleteUploadImgTaskPhoto },
  136. computed: {
  137. ...mapState({
  138. userInfo: (state) => state.user.userInfo,
  139. }),
  140. },
  141. data() {
  142. return {
  143. isEdit: true,
  144. formData: null,
  145. dataList: null,
  146. taskIds: [],
  147. visitsId: null,
  148. storeGroupId: '',
  149. objectType: '',
  150. insert: '',
  151. vanPopup: false,
  152. taskPhotoRecognitionResult: null,
  153. spanArr: [],
  154. pos: 0,
  155. mediaIds: [],
  156. };
  157. },
  158. activated() {
  159. this.taskIds = this.$route.query.taskIds || [];
  160. this.visitsId = this.$route.query.visitsId || '';
  161. this.storeGroupId = this.$route.query.storeGroupId || '';
  162. this.objectType = this.$route.query.photoType || '';
  163. this.insert = this.$route.query.insert;
  164. if (this.$route.query.source == 'historicalDetails') {
  165. this.getVisitsDetailFun();
  166. } else {
  167. this.getDetaile();
  168. }
  169. },
  170. beforeRouteLeave(to, from, next) {
  171. if (this.$refs.taskPhoto && this.$refs.taskPhoto[0]) {
  172. this.$refs.taskPhoto[0].imgArr = [];
  173. }
  174. next();
  175. },
  176. watch: {},
  177. methods: {
  178. taskObjectSpanMethod({ row, column, rowIndex, columnIndex }) {
  179. const cellValue = row[column.property];
  180. if (cellValue && ['conditionIdentifyNum'].includes(column.property)) {
  181. const _row = this.spanArr[rowIndex]; // 合并行数
  182. const _col = this.spanArr[rowIndex] > 0 ? 1 : 0; // 合并的列数
  183. return {
  184. rowspan: _row,
  185. colspan: _col,
  186. };
  187. }
  188. },
  189. getSpanArr(data) {
  190. if (!data) return;
  191. this.spanArr = []; // tip: 后台获取完成数据后,一定要重置spanArr=[],避免出现合并混乱!!!!!
  192. for (let i = 0; i < data.length; i++) {
  193. // 当为第一行时
  194. if (i === 0) {
  195. this.spanArr.push(1);
  196. this.pos = 0;
  197. } else {
  198. // 判断当前值是否与上一行的【名称】相等,相等则进行合并
  199. if (data[i].conditionDetailId === data[i - 1].conditionDetailId) {
  200. this.spanArr[this.pos] += 1; // 合并单元格:合并的行数 +1
  201. this.spanArr.push(0); // 0代表单元格是不需要显示, 已经被合并的单元格
  202. } else {
  203. this.spanArr.push(1); // 1代表当前这行的数据需要被显示
  204. this.pos = i;
  205. }
  206. }
  207. }
  208. },
  209. getVisitsDetailFun() {
  210. this.toastLoading(0, '加载中...', true);
  211. getVisitsDetail({ visitsId: this.visitsId }).then((res) => {
  212. this.toastLoading().clear();
  213. if (res.data.sfaTaskList) {
  214. this.dataList = res.data.sfaTaskList.filter((val) => val.taskType == '5');
  215. this.formData = this.dataList[0];
  216. } else {
  217. this.formData = null;
  218. }
  219. });
  220. },
  221. getDetaile() {
  222. console.log(this.$route.query);
  223. getCollectionInfosBatch({
  224. storeCode: this.$route.query.storeCode,
  225. insert: this.insert,
  226. id: this.visitsId,
  227. taskIds: this.taskIds.split(','),
  228. }).then((res) => {
  229. if (res.data && res.data.length) {
  230. this.dataList = res.data;
  231. this.formData = res.data[0];
  232. } else {
  233. this.formData = null;
  234. }
  235. });
  236. },
  237. openDialog(item) {
  238. this.vanPopup = true;
  239. console.log(item);
  240. this.getSpanArr(item.taskPhotoRecognitionResult);
  241. this.$nextTick(() => {
  242. console.log(this.spanArr);
  243. this.taskPhotoRecognitionResult = item.taskPhotoRecognitionResult;
  244. });
  245. },
  246. waitUploadReady(interval = 1000) {
  247. return new Promise((resolve) => {
  248. const intervalId = setInterval(() => {
  249. const taskPhoto = this.$refs.taskPhoto && this.$refs.taskPhoto[0];
  250. if (taskPhoto && taskPhoto.isUploadImg) {
  251. clearInterval(intervalId);
  252. resolve();
  253. }
  254. }, interval);
  255. });
  256. },
  257. async onSubmit() {
  258. this.toastLoading(0, '提交中,请稍候...', true);
  259. try {
  260. const taskPhoto = this.$refs.taskPhoto && this.$refs.taskPhoto[0];
  261. if (taskPhoto && !taskPhoto.isUploadImg) {
  262. await this.waitUploadReady(1000);
  263. }
  264. let formData = {
  265. storeId: this.$route.query.storeId,
  266. storeCode: this.$route.query.storeCode,
  267. storeGroupId: this.$route.query.storeGroupId,
  268. visitsId: this.visitsId,
  269. taskList: this.taskIds.split(',').map((val) => Number(val)),
  270. insert: true,
  271. collectionAnswers: [],
  272. checkUnManage: 'N',
  273. deviceCode: '',
  274. putInCode: '',
  275. equipmentCode: '',
  276. collectionItemId: taskPhoto ? taskPhoto.collectionItemId : '',
  277. objectType: this.$route.query.photoType,
  278. locationRemark: taskPhoto ? taskPhoto.locationRemark : '',
  279. mediaInfos: [],
  280. isH5: this.userInfo.photoMethod == '1',
  281. };
  282. if (this.userInfo.photoMethod == '1') {
  283. formData.mediaInfos = [];
  284. } else if (taskPhoto) {
  285. formData.mediaInfos = taskPhoto.imgArr;
  286. }
  287. await this.addCollection(formData);
  288. } catch (err) {
  289. this.$toast(err.message || '提交失败,请稍后再试');
  290. } finally {
  291. this.toastLoading().clear();
  292. }
  293. },
  294. addCollection(formData) {
  295. return addCollectionAnswerBatch(formData).then((res) => {
  296. if (res.code == 200) {
  297. localStorage.setItem('getRequestFlage', 'true');
  298. this.$router.go(-1);
  299. } else {
  300. this.$toast('提交失败,请重试');
  301. }
  302. });
  303. },
  304. onClickLeft() {
  305. this.$router.go(-1);
  306. },
  307. },
  308. };
  309. </script>
  310. <style lang="scss">
  311. .taskPhotoTaking {
  312. display: flex;
  313. flex-direction: column;
  314. width: 100%;
  315. height: 100%;
  316. overflow: hidden;
  317. .content {
  318. padding: 10px;
  319. flex: 1;
  320. width: 100%;
  321. height: 100%;
  322. display: flex;
  323. flex-direction: column;
  324. padding-bottom: 46px;
  325. .container {
  326. background: #fff;
  327. width: 100%;
  328. border-radius: 6px;
  329. // padding: 10px;
  330. padding: 0 10px 10px 0px;
  331. }
  332. .formLabel {
  333. // margin-left: 20px;
  334. // border-bottom: 1px solid #f1f1f1;
  335. }
  336. .formLabel .van-cell {
  337. padding: 10px 0;
  338. }
  339. .formLabel .van-cell::after {
  340. border: 0;
  341. }
  342. .formLabel .van-field {
  343. border: 1px solid #f1f1f1;
  344. padding: 6px;
  345. width: 100%;
  346. border-radius: 4px;
  347. overflow: hidden;
  348. }
  349. .formLabel .van-field__control {
  350. padding: 0 10px;
  351. }
  352. .formLabel .formLabeltitle {
  353. position: absolute;
  354. top: 8px;
  355. }
  356. .z-cell .van-cell__title {
  357. font-size: 16px;
  358. }
  359. .van-f-red {
  360. color: red;
  361. width: 8px;
  362. display: inline-block;
  363. line-height: 26px;
  364. }
  365. .headline {
  366. font-weight: 600;
  367. font-size: 16px;
  368. position: relative;
  369. display: flex;
  370. align-items: center;
  371. .headlineIcon {
  372. display: inline-block;
  373. position: absolute;
  374. width: 3px;
  375. height: 60%;
  376. background: #3875c6;
  377. border-radius: 5px;
  378. }
  379. .headlineTitle {
  380. display: inline-block;
  381. padding: 0px 20px;
  382. background: #eef5ff;
  383. border-radius: 0 18px 18px 0;
  384. height: 36px;
  385. line-height: 36px;
  386. }
  387. }
  388. }
  389. .dataList {
  390. width: 100%;
  391. margin-top: 10px;
  392. overflow-y: auto;
  393. background: #fff;
  394. .dataItem {
  395. display: flex;
  396. // border-radius: 6px;
  397. flex-direction: row;
  398. margin-bottom: 5px;
  399. // padding: 10px;
  400. font-size: 16px;
  401. margin-left: 20px;
  402. border-bottom: 1px solid #e2e1e1;
  403. .itemIndex {
  404. display: flex;
  405. flex-direction: row;
  406. }
  407. .itemTop {
  408. flex: 1;
  409. overflow: hidden;
  410. padding-bottom: 10px;
  411. .itemHtml {
  412. overflow-x: auto;
  413. margin-left: 20px;
  414. p {
  415. margin: 0;
  416. }
  417. }
  418. }
  419. .itemBottom {
  420. display: flex;
  421. flex-direction: row;
  422. }
  423. .itemBottom {
  424. align-items: center;
  425. width: 35px;
  426. margin-left: 5px;
  427. img {
  428. width: 100%;
  429. height: 30px;
  430. }
  431. button {
  432. width: 55px;
  433. height: 25px;
  434. padding: 0;
  435. font-size: 12px;
  436. }
  437. }
  438. }
  439. }
  440. }
  441. </style>
  442. <style lang="scss">
  443. // .taskPhotoTaking {
  444. // .itenHtml {
  445. // overflow: hidden;
  446. // img {
  447. // width: 100%;
  448. // }
  449. // }
  450. // }
  451. .identifyResultdialog {
  452. width: vw(690) !important;
  453. margin-top: 1vh !important;
  454. border-radius: 8px !important;
  455. font-size: vw(32) !important;
  456. height: 70% !important;
  457. display: flex;
  458. flex-direction: column;
  459. .el-dialog__headerbtn {
  460. width: vw(44);
  461. height: vw(44);
  462. background-color: #e1e1e1;
  463. border-radius: 50%;
  464. margin-top: -3px;
  465. }
  466. .el-dialog__body {
  467. flex: 1;
  468. overflow-y: auto;
  469. }
  470. }
  471. .table-headermd1 {
  472. font-size: 14px;
  473. text-align: center;
  474. position: initial;
  475. width: 98% !important;
  476. margin: 0 auto;
  477. border-right: 0;
  478. border-radius: 8px;
  479. th {
  480. color: #000;
  481. font-weight: bold;
  482. }
  483. td {
  484. color: #000;
  485. }
  486. .el-table__cell {
  487. padding: 6px 0 !important;
  488. .cell {
  489. padding: 0;
  490. }
  491. }
  492. }
  493. </style>