taskPhotoTaking.vue 13 KB

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