reportCustom.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <div class="reportCustom" v-if="fromData && fromData.length">
  3. <van-form ref="tabstoreVal" :readonly="disabled">
  4. <template v-for="(value, ind) in fromData">
  5. <template v-if="value.sfaReportCustomCollections">
  6. <div
  7. v-for="(item, index) in value.sfaReportCustomCollections"
  8. :key="item.reportCustomCollectionId">
  9. <div v-if="item.reportCustomCollectionType == 'sz'" class="formLabel z-cell">
  10. <van-cell>
  11. <template #title>
  12. <span v-if="item.isMust == '1'" class="van-f-red">*</span>
  13. {{ filterIndex(ind, index) + 1 + '.' }}
  14. {{ item.reportCustomCollectionName }}
  15. </template>
  16. </van-cell>
  17. <van-field
  18. :name="item.reportCustomCollectionName"
  19. v-model="item.answerValue"
  20. :placeholder="item.remark"
  21. type="number"
  22. @input="numberFn(item, index)"
  23. :rules="[
  24. {
  25. required: item.isMust == '1',
  26. message: item.remark || '请输入' + item.reportCustomCollectionName,
  27. },
  28. ]"></van-field>
  29. </div>
  30. <div v-if="item.reportCustomCollectionType == 'wb'" class="formLabel z-cell">
  31. <van-cell>
  32. <template #title>
  33. <span v-if="item.isMust == '1'" class="van-f-red">*</span>
  34. {{ filterIndex(ind, index) + 1 + '.' }}
  35. {{ item.reportCustomCollectionName }}
  36. </template>
  37. </van-cell>
  38. <van-field
  39. :name="item.reportCustomCollectionName"
  40. v-model="item.answerValue"
  41. :formatter="formatter"
  42. autosize
  43. type="textarea"
  44. maxlength="800"
  45. :placeholder="item.remark"
  46. :rules="[
  47. {
  48. required: item.isMust == '1',
  49. message: item.remark || '请输入' + item.reportCustomCollectionName,
  50. },
  51. ]"></van-field>
  52. </div>
  53. <div v-if="item.reportCustomCollectionType == 'duox'" class="formLabel z-cell">
  54. <van-cell>
  55. <template #title>
  56. <span v-if="item.isMust == '1'" class="van-f-red">*</span>
  57. {{ filterIndex(ind, index) + 1 + '.' }}
  58. {{ item.reportCustomCollectionName }}
  59. </template>
  60. </van-cell>
  61. <van-field
  62. :name="item.reportCustomCollectionName"
  63. :rules="[
  64. {
  65. required: item.isMust == '1',
  66. message: '请选择' + item.reportCustomCollectionName,
  67. },
  68. ]">
  69. <template #input>
  70. <z-checkbox
  71. :textc="item.reportCustomOptionId"
  72. :zCheckboxcolumns="item.sfaReportCustomOptions"
  73. :id="'reportCustomOptionId'"
  74. :disabled="disabled"
  75. @zSelectVal="zSelectVal"></z-checkbox>
  76. </template>
  77. </van-field>
  78. <p style="color: red; font-size: 12px; margin: 0; text-align: right">
  79. {{ item.remark }}
  80. </p>
  81. </div>
  82. <div v-if="item.reportCustomCollectionType == 'dx'" class="formLabel z-cell">
  83. <van-cell>
  84. <template #title>
  85. <span v-if="item.isMust == '1'" class="van-f-red">*</span>
  86. {{ filterIndex(ind, index) + 1 + '.' }}
  87. {{ item.reportCustomCollectionName }}
  88. </template>
  89. </van-cell>
  90. <van-field
  91. :name="item.reportCustomCollectionName"
  92. :rules="[
  93. {
  94. required: item.isMust == '1',
  95. message: '请选择' + item.reportCustomCollectionName,
  96. },
  97. ]">
  98. <template #input>
  99. <z-radio
  100. :answerType="item.reportCustomCollectionType"
  101. :collectionType="item.collectionType"
  102. :textc="item.reportCustomOptionId"
  103. :zRadiocolumns="item.sfaReportCustomOptions"
  104. :id="'reportCustomOptionId'"
  105. :disabled="disabled"
  106. @zSelectVal="zSelectVal"></z-radio>
  107. </template>
  108. </van-field>
  109. <p style="color: red; font-size: 12px; margin: 0; text-align: right">
  110. {{ item.remark }}
  111. </p>
  112. </div>
  113. </div>
  114. </template>
  115. </template>
  116. </van-form>
  117. </div>
  118. </template>
  119. <script>
  120. import zRadio from '@/components/componentZRadio';
  121. import zCheckbox from '@/components/componentZCheckbox';
  122. export default {
  123. components: { zRadio, zCheckbox },
  124. props: {
  125. reportCustomData: {
  126. type: Array,
  127. default: () => [],
  128. },
  129. disabled: {
  130. type: Boolean,
  131. default: false,
  132. },
  133. },
  134. watch: {
  135. reportCustomData: {
  136. handler(val) {
  137. this.postName = localStorage.getItem('postName');
  138. this.filterFromData(val);
  139. },
  140. immediate: true,
  141. deep: true,
  142. },
  143. },
  144. data() {
  145. return {
  146. fromData: null,
  147. postName: '',
  148. };
  149. },
  150. methods: {
  151. filterIndex(index, subIndex) {
  152. let count = 0;
  153. for (let i = 0; i < index; i++) {
  154. count += this.fromData[i].sfaReportCustomCollections
  155. ? this.fromData[i].sfaReportCustomCollections.length
  156. : 0;
  157. }
  158. return count + subIndex;
  159. },
  160. filterFromData(val) {
  161. // 公装销售专员 写死 不用填写 未拜访原因
  162. // if (this.postName == '公装销售专员') {
  163. // let fromData = JSON.parse(JSON.stringify(val));
  164. // let reportCustomAnswers = [];
  165. // for (let i = 0; i < fromData.length; i++) {
  166. // let arr1 = fromData[i];
  167. // let sfaReportCustomCollections = [];
  168. // let customData = fromData[i].sfaReportCustomCollections
  169. // ? fromData[i].sfaReportCustomCollections
  170. // : [];
  171. // for (let x = 0; x < customData.length; x++) {
  172. // // sameDayWhetherVisit 2 未拜访
  173. // if (customData[x].sameDayWhetherVisit != '2') {
  174. // sfaReportCustomCollections.push(customData[x]);
  175. // }
  176. // }
  177. // arr1.sfaReportCustomCollections = sfaReportCustomCollections;
  178. // reportCustomAnswers.push(arr1);
  179. // }
  180. // console.log(reportCustomAnswers);
  181. // this.fromData = reportCustomAnswers;
  182. // } else {
  183. this.fromData = val;
  184. // }
  185. },
  186. numberFn(val, index) {
  187. if (val.answerValue) {
  188. if (!/^[+-]?\d*\.{0,1}\d{0,1}$/.test(val.answerValue)) {
  189. val.answerValue = val.answerValue.replace(
  190. /\.\d{2,}$/,
  191. val.answerValue.substr(val.answerValue.indexOf('.'), 3),
  192. );
  193. }
  194. }
  195. },
  196. formatter(value) {
  197. return value.replace(
  198. /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/gi,
  199. '',
  200. );
  201. },
  202. zSelectVal(value) {
  203. console.log(value);
  204. // var collectionAnswerlisd = this.collectionAnswerlisd;
  205. // if (collectionAnswerlisd.length > 0) {
  206. // var num = 0;
  207. // for (var a = 0; a < collectionAnswerlisd.length; a++) {
  208. // if (collectionAnswerlisd[a].id == value.id) {
  209. // collectionAnswerlisd[a] = value;
  210. // num = 0;
  211. // } else {
  212. // num = 1;
  213. // }
  214. // }
  215. // if (num > 0) {
  216. // collectionAnswerlisd.push(value);
  217. // }
  218. // } else {
  219. // collectionAnswerlisd.push(value);
  220. // }
  221. // this.collectionAnswerlisd = collectionAnswerlisd;
  222. },
  223. },
  224. };
  225. </script>
  226. <style lang="scss">
  227. .reportCustom {
  228. .van-f-red {
  229. color: red;
  230. width: 8px;
  231. display: inline-block;
  232. line-height: 26px;
  233. }
  234. .formLabel {
  235. // margin: 0 16px;
  236. border-bottom: 1px solid #f1f1f1;
  237. }
  238. .formLabel .van-cell {
  239. padding: 10px 0;
  240. }
  241. .formLabel .van-cell::after {
  242. border: 0;
  243. }
  244. .formLabel .van-field {
  245. border: 1px solid #f1f1f1;
  246. padding: 0;
  247. width: 100%;
  248. border-radius: 4px;
  249. overflow: hidden;
  250. }
  251. .van-field__control {
  252. background-color: white !important;
  253. padding: 0 10px;
  254. }
  255. .formLabel .formLabeltitle {
  256. position: absolute;
  257. top: 8px;
  258. }
  259. .lineGrey {
  260. height: 10px;
  261. width: 100%;
  262. background: #f1f1f1;
  263. }
  264. .z-checkbox .van-radio {
  265. padding: 6px 0;
  266. }
  267. .z-cell .van-cell__title {
  268. font-size: 16px;
  269. }
  270. .van-form {
  271. background-color: white;
  272. }
  273. }
  274. </style>