taskPhotoTaking.vue 14 KB

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