taskPhotoTaking.vue 16 KB

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