taskPhotoTaking.vue 13 KB

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