taskPhotoTaking.vue 16 KB

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