taskPhotoTaking.vue 15 KB

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