taskPhotoTaking.vue 14 KB

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