taskPhotoTaking.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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="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 {
  130. getCollectionInfosBatch,
  131. addCollectionAnswerBatch,
  132. getVisitsDetail,
  133. selectUserDistanceTheStore,
  134. } from '@/api/index';
  135. import taskTips from './taskTips';
  136. import deleteUploadImgTaskPhoto from '@/components/deleteUploadImgTaskPhoto';
  137. import { getPosition, getTicketFun } from '@/utils/TXApiFun';
  138. import { mapState } from 'vuex';
  139. export default {
  140. name: 'abnortaskPhotoTakingmalVisit',
  141. components: { taskTips, deleteUploadImgTaskPhoto },
  142. computed: {
  143. ...mapState({
  144. userInfo: (state) => state.user.userInfo,
  145. }),
  146. },
  147. data() {
  148. return {
  149. formData: null,
  150. dataList: null,
  151. taskIds: [],
  152. visitsId: null,
  153. storeGroupId: '',
  154. objectType: '',
  155. insert: '',
  156. vanPopup: false,
  157. taskPhotoRecognitionResult: null,
  158. spanArr: [],
  159. pos: 0,
  160. mediaIds: [],
  161. mediaInfos: [],
  162. editFlag: true,
  163. };
  164. },
  165. activated() {
  166. this.taskIds = this.$route.query.taskIds || [];
  167. this.visitsId = this.$route.query.visitsId || '';
  168. this.storeGroupId = this.$route.query.storeGroupId || '';
  169. this.objectType = this.$route.query.photoType || '';
  170. this.insert = this.$route.query.insert;
  171. // 授权
  172. // getTicketFun(['uploadImage']).then(() => {});
  173. if (this.$route.query.source == 'historicalDetails') {
  174. this.getVisitsDetailFun();
  175. } else {
  176. this.getDetaile();
  177. }
  178. },
  179. beforeRouteLeave(to, from, next) {
  180. if (this.$refs.taskPhoto && this.$refs.taskPhoto[0]) {
  181. this.$refs.taskPhoto[0].imgArr = [];
  182. }
  183. next();
  184. },
  185. watch: {},
  186. methods: {
  187. // 授权
  188. getTicketFunfun() {
  189. getTicketFun()
  190. .then(() => {
  191. getPosition()
  192. .then((res) => {
  193. let { TXisBD } = res;
  194. // this.lat = TXisBD.lat;
  195. // this.lon = TXisBD.lon;
  196. this.selectUserDistanceTheStoreFun(TXisBD);
  197. })
  198. .catch((error) => {
  199. this.$dialog.alert({
  200. message: error,
  201. });
  202. });
  203. })
  204. .catch(() => {});
  205. },
  206. selectUserDistanceTheStoreFun(TXisBD) {
  207. selectUserDistanceTheStore({
  208. visitsId: this.visitsId, // Long 拜访id
  209. lon: TXisBD.lon, // String 经度
  210. lat: TXisBD.lat, // String 纬度
  211. }).then((res) => {
  212. if (res.code == 200) {
  213. this.editFlag = true;
  214. } else {
  215. this.editFlag = true;
  216. this.$toast(res.msg);
  217. }
  218. });
  219. },
  220. taskObjectSpanMethod({ row, column, rowIndex, columnIndex }) {
  221. const cellValue = row[column.property];
  222. if (cellValue && ['conditionIdentifyNum'].includes(column.property)) {
  223. const _row = this.spanArr[rowIndex]; // 合并行数
  224. const _col = this.spanArr[rowIndex] > 0 ? 1 : 0; // 合并的列数
  225. return {
  226. rowspan: _row,
  227. colspan: _col,
  228. };
  229. }
  230. },
  231. getSpanArr(data) {
  232. if (!data) return;
  233. this.spanArr = []; // tip: 后台获取完成数据后,一定要重置spanArr=[],避免出现合并混乱!!!!!
  234. for (let i = 0; i < data.length; i++) {
  235. // 当为第一行时
  236. if (i === 0) {
  237. this.spanArr.push(1);
  238. this.pos = 0;
  239. } else {
  240. // 判断当前值是否与上一行的【名称】相等,相等则进行合并
  241. if (data[i].conditionDetailId === data[i - 1].conditionDetailId) {
  242. this.spanArr[this.pos] += 1; // 合并单元格:合并的行数 +1
  243. this.spanArr.push(0); // 0代表单元格是不需要显示, 已经被合并的单元格
  244. } else {
  245. this.spanArr.push(1); // 1代表当前这行的数据需要被显示
  246. this.pos = i;
  247. }
  248. }
  249. }
  250. },
  251. getVisitsDetailFun() {
  252. this.toastLoading(0, '加载中...', true);
  253. getVisitsDetail({ visitsId: this.visitsId }).then((res) => {
  254. this.toastLoading().clear();
  255. if (res.data.sfaTaskList) {
  256. this.dataList = res.data.sfaTaskList.filter((val) => val.taskType == '5');
  257. this.formData = this.dataList[0];
  258. this.isEditFun();
  259. } else {
  260. this.formData = null;
  261. }
  262. });
  263. },
  264. getDetaile() {
  265. console.log(this.$route.query);
  266. getCollectionInfosBatch({
  267. storeCode: this.$route.query.storeCode,
  268. insert: this.insert,
  269. id: this.visitsId,
  270. taskIds: this.taskIds.split(','),
  271. }).then((res) => {
  272. if (res.data && res.data.length) {
  273. this.dataList = res.data;
  274. this.formData = res.data[0];
  275. this.isEditFun();
  276. } else {
  277. this.formData = null;
  278. }
  279. });
  280. },
  281. isEditFun() {
  282. this.getTicketFunfun();
  283. },
  284. openDialog(item) {
  285. this.vanPopup = true;
  286. console.log(item);
  287. this.getSpanArr(item.taskPhotoRecognitionResult);
  288. this.$nextTick(() => {
  289. console.log(this.spanArr);
  290. this.taskPhotoRecognitionResult = item.taskPhotoRecognitionResult;
  291. });
  292. },
  293. onSubmit() {
  294. this.toastLoading(0, '提交中,请稍候...', true);
  295. const taskPhoto = this.$refs.taskPhoto && this.$refs.taskPhoto[0];
  296. let formData = {
  297. storeId: this.$route.query.storeId,
  298. storeCode: this.$route.query.storeCode,
  299. storeGroupId: this.$route.query.storeGroupId,
  300. visitsId: this.visitsId,
  301. taskList: this.taskIds.split(',').map((val) => Number(val)),
  302. insert: true,
  303. collectionAnswers: [],
  304. checkUnManage: 'N',
  305. deviceCode: '',
  306. putInCode: '',
  307. equipmentCode: '',
  308. collectionItemId: taskPhoto ? taskPhoto.collectionItemId : '',
  309. objectType: this.$route.query.photoType,
  310. locationRemark: taskPhoto ? taskPhoto.locationRemark : '',
  311. mediaInfos: [],
  312. isH5: this.userInfo.photoMethod == '1',
  313. };
  314. if (this.userInfo.photoMethod == '1') {
  315. formData.mediaInfos = [];
  316. this.addCollection(formData);
  317. } else {
  318. this.mediaInfos = [];
  319. let imgArr = JSON.parse(JSON.stringify(taskPhoto.imgArr));
  320. this.syncUpload(imgArr, () => {
  321. this.toastLoading().clear();
  322. formData.mediaInfos = this.mediaInfos;
  323. this.addCollection(formData);
  324. });
  325. }
  326. },
  327. syncUpload(imgArr, callback) {
  328. if (!imgArr.length) {
  329. callback && callback();
  330. return;
  331. } else {
  332. var item = imgArr.pop();
  333. if (!item.mediaId) {
  334. wx.uploadImage({
  335. localId: item.mediaFileUrl,
  336. isShowProgressTips: 0, // 默认为1,显示进度提示
  337. success: (res) => {
  338. this.mediaInfos.push({
  339. mediaId: res.serverId,
  340. mediaFileUrl: item.mediaFileUrl,
  341. });
  342. this.syncUpload(imgArr, callback);
  343. },
  344. });
  345. } else {
  346. this.mediaInfos.push(item);
  347. this.syncUpload(imgArr, callback);
  348. }
  349. }
  350. },
  351. addCollection(formData) {
  352. return addCollectionAnswerBatch(formData).then((res) => {
  353. if (res.code == 200) {
  354. localStorage.setItem('getRequestFlage', 'true');
  355. this.$router.go(-1);
  356. } else {
  357. this.$toast('提交失败,请重试');
  358. }
  359. });
  360. },
  361. onClickLeft() {
  362. this.$router.go(-1);
  363. },
  364. },
  365. };
  366. </script>
  367. <style lang="scss">
  368. .taskPhotoTaking {
  369. display: flex;
  370. flex-direction: column;
  371. width: 100%;
  372. height: 100%;
  373. overflow: hidden;
  374. .content {
  375. padding: 10px;
  376. flex: 1;
  377. width: 100%;
  378. height: 100%;
  379. display: flex;
  380. flex-direction: column;
  381. padding-bottom: 46px;
  382. // overflow-y: auto;
  383. .container {
  384. background: #fff;
  385. width: 100%;
  386. border-radius: 6px;
  387. // padding: 10px;
  388. padding: 0 10px 10px 0px;
  389. }
  390. .formLabel {
  391. // margin-left: 20px;
  392. // border-bottom: 1px solid #f1f1f1;
  393. }
  394. .formLabel .van-cell {
  395. padding: 10px 0;
  396. }
  397. .formLabel .van-cell::after {
  398. border: 0;
  399. }
  400. .formLabel .van-field {
  401. border: 1px solid #f1f1f1;
  402. padding: 6px;
  403. width: 100%;
  404. border-radius: 4px;
  405. overflow: hidden;
  406. }
  407. .formLabel .van-field__control {
  408. padding: 0 10px;
  409. }
  410. .formLabel .formLabeltitle {
  411. position: absolute;
  412. top: 8px;
  413. }
  414. .z-cell .van-cell__title {
  415. font-size: 16px;
  416. }
  417. .van-f-red {
  418. color: red;
  419. width: 8px;
  420. display: inline-block;
  421. line-height: 26px;
  422. }
  423. .headline {
  424. font-weight: 600;
  425. font-size: 16px;
  426. position: relative;
  427. display: flex;
  428. align-items: center;
  429. .headlineIcon {
  430. display: inline-block;
  431. position: absolute;
  432. width: 3px;
  433. height: 60%;
  434. background: #3875c6;
  435. border-radius: 5px;
  436. }
  437. .headlineTitle {
  438. display: inline-block;
  439. padding: 0px 20px;
  440. background: #eef5ff;
  441. border-radius: 0 18px 18px 0;
  442. height: 36px;
  443. line-height: 36px;
  444. }
  445. }
  446. }
  447. .dataList {
  448. width: 100%;
  449. margin-top: 10px;
  450. overflow-y: auto;
  451. background: #fff;
  452. .dataItem {
  453. display: flex;
  454. // border-radius: 6px;
  455. flex-direction: row;
  456. margin-bottom: 5px;
  457. // padding: 10px;
  458. font-size: 16px;
  459. margin-left: 20px;
  460. border-bottom: 1px solid #e2e1e1;
  461. .itemIndex {
  462. display: flex;
  463. flex-direction: row;
  464. }
  465. .itemTop {
  466. flex: 1;
  467. overflow: hidden;
  468. padding-bottom: 10px;
  469. .itemHtml {
  470. overflow-x: auto;
  471. margin-left: 20px;
  472. p {
  473. margin: 0;
  474. }
  475. }
  476. }
  477. .itemBottom {
  478. display: flex;
  479. flex-direction: row;
  480. }
  481. .itemBottom {
  482. align-items: center;
  483. width: 35px;
  484. margin-left: 5px;
  485. img {
  486. width: 100%;
  487. height: 30px;
  488. }
  489. button {
  490. width: 55px;
  491. height: 25px;
  492. padding: 0;
  493. font-size: 12px;
  494. }
  495. }
  496. }
  497. }
  498. }
  499. </style>
  500. <style lang="scss">
  501. // .taskPhotoTaking {
  502. // .itenHtml {
  503. // overflow: hidden;
  504. // img {
  505. // width: 100%;
  506. // }
  507. // }
  508. // }
  509. .identifyResultdialog {
  510. width: vw(690) !important;
  511. margin-top: 1vh !important;
  512. border-radius: 8px !important;
  513. font-size: vw(32) !important;
  514. height: 70% !important;
  515. display: flex;
  516. flex-direction: column;
  517. .el-dialog__headerbtn {
  518. width: vw(44);
  519. height: vw(44);
  520. background-color: #e1e1e1;
  521. border-radius: 50%;
  522. margin-top: -3px;
  523. }
  524. .el-dialog__body {
  525. flex: 1;
  526. overflow-y: auto;
  527. }
  528. }
  529. .table-headermd1 {
  530. font-size: 14px;
  531. text-align: center;
  532. position: initial;
  533. width: 98% !important;
  534. margin: 0 auto;
  535. border-right: 0;
  536. border-radius: 8px;
  537. th {
  538. color: #000;
  539. font-weight: bold;
  540. }
  541. td {
  542. color: #000;
  543. }
  544. .el-table__cell {
  545. padding: 6px 0 !important;
  546. .cell {
  547. padding: 0;
  548. }
  549. }
  550. }
  551. </style>