allowWriteAgainSummary.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. <template>
  2. <div class="componVisitSummary">
  3. <slot></slot>
  4. <van-form ref="tabstoreVal">
  5. <div v-for="(item, index) in collectionItemList" :key="index">
  6. <div v-if="item.answerType == 'sz'" class="formLabel z-cell">
  7. <van-cell>
  8. <template #title>
  9. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  10. {{ 1 + index + '.' }}
  11. {{ item.customName }}
  12. </template>
  13. </van-cell>
  14. <!-- allowWriteAgain 是否允许补填 true/false -->
  15. <van-field v-model="item.answerValue" :placeholder="item.remark" type="number"
  16. :disabled="!item.allowWriteAgain" @input="numberFn(item, index)"></van-field>
  17. <!-- <p
  18. v-if="item.allowWriteAgain"
  19. style="color: #444; font-size: 12px; margin: 0; padding: 10px 0; text-align: right">
  20. {{ item.remark }}
  21. </p> -->
  22. </div>
  23. <div v-if="item.answerType == 'rq'" class="formLabel z-cell">
  24. <van-cell>
  25. <template #title>
  26. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  27. {{ 1 + index + '.' }}
  28. {{ item.customName }}
  29. </template>
  30. </van-cell>
  31. <van-field v-model="item.answerValue" clickable name="calendar" placeholder="点击选择日期" readonly
  32. :disabled="!item.allowWriteAgain" @click="showCalendarClick(item, index)" />
  33. <p v-if="item.allowWriteAgain"
  34. style="color: #444; font-size: 12px; margin: 0; padding: 10px 0; text-align: right">
  35. {{ item.remark }}
  36. </p>
  37. </div>
  38. <div v-if="item.answerType == 'zp'" class="formLabel z-cell">
  39. <van-cell>
  40. <template #title>
  41. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  42. {{ 1 + index + '.' }}
  43. {{ item.customName }}
  44. </template>
  45. </van-cell>
  46. <van-row gutter="10" style="margin-bottom: 10px">
  47. <p v-if="item.allowWriteAgain" style="margin-top: 0">
  48. <span style="font-size: 12px; color: #888">{{ item.remark }}</span>
  49. </p>
  50. <delete-upload-img :isDelete="false" :imgs="item.fileInfoList"
  51. :isEdit="item.allowWriteAgain"></delete-upload-img>
  52. <upload-img v-if="item.allowWriteAgain" :uploadid="uploadid2" @newimgarr="newimgarr1" imgText="上传照片"
  53. :indexImg="index" :customId="item.customId" :summaryId="item.summaryId"
  54. :allowWriteAgain="item.allowWriteAgain" :item="item" @click="imgClick(item, index)"></upload-img>
  55. </van-row>
  56. </div>
  57. <div v-if="item.answerType == 'wb'" class="formLabel z-cell">
  58. <van-cell>
  59. <template #title>
  60. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  61. {{ 1 + index + '.' }}
  62. {{ item.customName }}
  63. </template>
  64. </van-cell>
  65. <van-field :disabled="!item.allowWriteAgain" v-model="item.answerValue" :formatter="formatter" autosize
  66. type="textarea" :placeholder="item.remark"></van-field>
  67. <!-- <p
  68. v-if="item.allowWriteAgain"
  69. style="color: #444; font-size: 12px; margin: 0; padding: 10px 0; text-align: right">
  70. {{ item.remark }}
  71. </p> -->
  72. </div>
  73. <div class="formLabel z-cell z-cells z-celly"
  74. v-if="item.answerType == 'gs' || item.answerType == 'dq' || item.answerType == 'xsb'">
  75. <van-cell>
  76. <template #title>
  77. {{ 1 + index + '.' }}
  78. {{ item.customName }}
  79. <span v-if="item.allowWriteAgain"
  80. style="color: #444; font-size: 12px; margin: 0; padding: 10px 0; text-align: right">{{ item.remark
  81. }}</span></template>
  82. </van-cell>
  83. <p class="mg0">{{ item.answerName }}</p>
  84. </div>
  85. <div v-if="item.answerType == 'duox'" class="formLabel z-cell">
  86. <van-cell>
  87. <template #title>
  88. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  89. {{ 1 + index + '.' }}
  90. {{ item.customName }}
  91. </template>
  92. </van-cell>
  93. <z-checkbox :disabled="!item.allowWriteAgain" :answerType="item.answerType" :checkboxval="item.answerValue"
  94. :collectionType="item.customOptionList" :textc="item.customId" :zCheckboxcolumns="item.customOptionList"
  95. @zSelectVal="zSelectVal"></z-checkbox>
  96. </div>
  97. <div v-if="item.answerType == 'dx'" class="formLabel z-cell">
  98. <van-cell>
  99. <template #title>
  100. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  101. {{ 1 + index + '.' }}
  102. {{ item.customName }}
  103. </template>
  104. </van-cell>
  105. <z-radio :disabled="!item.allowWriteAgain" :answerType="item.answerType" :collectionType="item.collectionType"
  106. :radio="item.answerValue" :textc="item.customId" :zRadiocolumns="item.customOptionList"
  107. @zSelectVal="zSelectVal"></z-radio>
  108. </div>
  109. <div v-if="item.answerType == 'jxs' || item.answerType == 'md'" class="formLabel z-cell">
  110. <van-cell>
  111. <template #title>
  112. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  113. {{ 1 + index + '.' }}
  114. {{ item.customName }}
  115. </template>
  116. </van-cell>
  117. <div class="jxsBox">
  118. <div class="jxsContent" v-if="item.answerType == 'jxs'">
  119. <div class="item" v-for="(val, index) in item.chainList" :key="index">
  120. <el-popover placement="bottom" trigger="click" :content="val.chainName + '(' + val.chainCode + ')'">
  121. <template slot="reference">
  122. <div class="selectItem">{{ val.chainName }} &nbsp; ({{ val.chainCode }})</div>
  123. <van-icon name="clear" size="16" @click="closeJXSorMD(item, index)" />
  124. </template>
  125. </el-popover>
  126. </div>
  127. </div>
  128. <div class="jxsContent" v-if="item.answerType == 'md'">
  129. <div class="item" v-for="(val, index) in item.storeList" :key="index">
  130. <el-popover placement="bottom" trigger="click" :content="val.storeName + '(' + val.storeCode + ')'">
  131. <template slot="reference">
  132. <div class="selectItem">{{ val.storeName }} &nbsp; ({{ val.storeCode }})</div>
  133. <van-icon name="clear" size="16" @click="closeJXSorMD(item, index)" />
  134. </template>
  135. </el-popover>
  136. </div>
  137. </div>
  138. <div class="addJXS"><van-icon name="add-o" size="24" @click="addJXSorMD(item, index)" /></div>
  139. <div class="tips">{{ item.remark }}</div>
  140. </div>
  141. </div>
  142. <br />
  143. </div>
  144. </van-form>
  145. <van-calendar v-model="showCalendar" @confirm="onConfirm" color="#0057ba" :min-date="minDate" :max-date="maxDate"
  146. :show-confirm="false" />
  147. <van-popup v-model="RegionShow" capture position="bottom">
  148. <van-picker :columns="companyList" show-toolbar value-key="deptName" @cancel="RegionShow = false"
  149. @confirm="onregionConfirm" />
  150. </van-popup>
  151. <van-popup v-model="SalesRegionShow" capture position="bottom">
  152. <van-picker :columns="regionList" show-toolbar value-key="deptName" @cancel="SalesRegionShow = false"
  153. @confirm="onSalesRegionConfirm" />
  154. </van-popup>
  155. <van-popup v-model="SalesDepartmentShow" capture position="bottom">
  156. <van-picker :columns="deptList" show-toolbar value-key="deptName" @cancel="SalesDepartmentShow = false"
  157. @confirm="onSalesDepartmentConfirm" />
  158. </van-popup>
  159. <van-popup v-model="StartTimeShow" capture position="bottom">
  160. <van-datetime-picker v-model="strtcurrentDate" :max-date="strtmaxDate" :min-date="strtminDate" title="选择查找开始时间"
  161. type="date" @cancel="StartTimeShow = false" @confirm="onStartTimeConfirm" />
  162. </van-popup>
  163. <van-popup v-model="EndTimeShow" capture position="bottom">
  164. <van-datetime-picker v-model="endcurrentDate" :max-date="endmaxDate" :min-date="endminDate" title="选择查找结束时间"
  165. type="date" @cancel="EndTimeShow = false" @confirm="onEndTimeConfirm" />
  166. </van-popup>
  167. <!-- 经销商 -->
  168. <van-popup v-model="moreTypeShow" position="bottom">
  169. <van-row style="background-color: #f5f5f5">
  170. <van-col span="20">
  171. <van-field left-icon="search" style="margin-top: 2px; border-radius: 6px; overflow: hidden"
  172. v-model="agentValue" label="" placeholder="请输入关键词" clearable />
  173. </van-col>
  174. <van-col span="4" style="text-align: center; line-height: 48px" @click="getChainsList(agentValue)">
  175. <div style="background-color: #0057ba; color: #fff">搜索</div>
  176. </van-col>
  177. </van-row>
  178. <van-picker show-toolbar :columns="chainsData" value-key="chainName" @confirm="onConfirmChainsList"
  179. @cancel="moreTypeShow = false" />
  180. </van-popup>
  181. <!-- 门店 -->
  182. <van-popup v-model="storeTypeShow" position="bottom">
  183. <van-row style="background-color: #f5f5f5">
  184. <van-col span="20">
  185. <van-field left-icon="search" style="margin-top: 2px; border-radius: 6px; overflow: hidden"
  186. v-model="agentValue" label="" placeholder="请输入门店名称/编号/地址搜索" clearable />
  187. </van-col>
  188. <van-col span="4" style="text-align: center; line-height: 48px" @click="getStoresList(agentValue)">
  189. <div style="background-color: #0057ba; color: #fff">搜索</div>
  190. </van-col>
  191. </van-row>
  192. <van-picker show-toolbar :columns="storesData" value-key="storeName" @confirm="onConfirmStoresList"
  193. @cancel="storeTypeShow = false" />
  194. </van-popup>
  195. </div>
  196. </template>
  197. <script>
  198. import {
  199. insertCustomAnswer,
  200. getSummaryMobileDeptInfo,
  201. getDeptsByUser,
  202. chainsList,
  203. storesList
  204. } from '@/api/index';
  205. import zRadio from '@/components/zRadio2';
  206. import zCheckbox from '@/components/zCheckbox2';
  207. import uploadImg from '@/components/uploadVTask';
  208. import deleteUploadImg from '@/components/deleteUploadImg2';
  209. export default {
  210. name: 'allowWriteAgainSummary',
  211. components: { zRadio, zCheckbox, uploadImg, deleteUploadImg },
  212. props: {
  213. collectionItemLists: {
  214. type: Array,
  215. default() {
  216. return [];
  217. },
  218. },
  219. },
  220. data() {
  221. return {
  222. RegionShow: false,
  223. SalesRegionShow: false,
  224. SalesDepartmentShow: false,
  225. StaffShow: false,
  226. StartTimeShow: false,
  227. dateIndex: '',
  228. EndTimeShow: false,
  229. uploadid2: 'uploadid2',
  230. PhotoTypeList: [{ text: '009', value: '09' }],
  231. strtminDate: new Date(2022, 0, 1),
  232. endminDate: new Date(2022, 0, 1),
  233. minDate: new Date(2020, 0, 1),
  234. maxDate: new Date(2090, 0, 31),
  235. strtmaxDate: new Date(),
  236. endmaxDate: new Date(),
  237. strtcurrentDate: new Date(),
  238. endcurrentDate: new Date(),
  239. companyName: '全部公司',
  240. deptName: '全部销售部',
  241. regionName: '全部大区',
  242. userName: '全部',
  243. companyCode: '',
  244. deptCode: '',
  245. regionCode: '',
  246. userCode: '',
  247. companyList: [],
  248. title: '',
  249. deptList: [],
  250. regionList: [],
  251. userList: [],
  252. deptForm: { type: '', parentId: '' },
  253. list: [],
  254. loading: false,
  255. finished: true,
  256. showCalendar: false,
  257. formData: {
  258. type: '2', // 汇报类型或入口 1-下属业务员日报 2-下属销售部主管周报 3-下属大区主管半月报
  259. companyId: '', // 公司id,必传 Long类型
  260. regionId: '', // 大区id,必传 Long类型
  261. deptId: '', // 部门id,如果为周报或日报为必传 Long类型
  262. userId: '', // 业务员id,如果为日报为必传 Long类型
  263. startTime: '', // 开始时间,必传 格式:yyyy-MM-dd String类型
  264. endTime: '', // 结束时间,必传 格式:yyyy-MM-dd String类型
  265. pageNum: 1, // 当前页码 int类型
  266. pageSize: 10, // 当前每页条数 int类型
  267. },
  268. tableList: [],
  269. collectionItemList: [],
  270. collectionAnswerlisd: [],
  271. flagclick: true,
  272. index: '',
  273. activaFlag: true,
  274. moreTypeShow: false,
  275. storeTypeShow: false,
  276. storeType: null,
  277. agentValue: '',
  278. selectIndex: 0,
  279. chainsData: [],
  280. storesData: [],
  281. chainName: '',
  282. chainCode: '',
  283. jxsList: [],
  284. };
  285. },
  286. created() {
  287. this.formData.startTime = this.getThreeDaysAgo();
  288. this.strtcurrentDate = new Date(this.getThreeDaysAgo());
  289. this.formData.endTime = this.parseTime(new Date(), '{y}-{m}-{d}') + '';
  290. this.endminDate = new Date(this.GetPreMonthDay(this.parseTime(new Date(), '{y}-{m}-{d}'), 2));
  291. this.powerGrade = localStorage.getItem('powerGrade');
  292. this.title = this.$route.query.title;
  293. this.regionCode = '';
  294. },
  295. watch: {
  296. collectionItemLists: {
  297. handler(val) {
  298. // this.collectionItemList = JSON.parse(JSON.stringify(this.collectionItemLists));
  299. this.setCollectionItemLists();
  300. },
  301. deep: true,
  302. immediate: true,
  303. },
  304. },
  305. methods: {
  306. showCalendarClick(item, index) {
  307. if (!item.allowWriteAgain) return;
  308. this.dateIndex = index;
  309. this.showCalendar = true;
  310. },
  311. formatDate(date) {
  312. var Month = date.getMonth() + 1;
  313. var Day = date.getDate();
  314. if (Month < 10) {
  315. Month = '0' + Month;
  316. }
  317. if (Day < 10) {
  318. Day = '0' + Day;
  319. }
  320. return `${date.getFullYear()}-${Month}-${Day}`;
  321. },
  322. onConfirm(date) {
  323. this.showCalendar = false;
  324. this.collectionItemList[this.dateIndex].answerValue = this.formatDate(date);
  325. },
  326. formatter(value) {
  327. return value.replace(
  328. /[\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,
  329. ''
  330. );
  331. },
  332. numberFn(val, index) {
  333. if (this.collectionItemList[index].answerName) {
  334. if (!/^[+-]?\d*\.{0,1}\d{0,1}$/.test(this.collectionItemList[index].answerName)) {
  335. this.collectionItemList[index].answerName = this.collectionItemList[
  336. index
  337. ].answerName.replace(
  338. /\.\d{2,}$/,
  339. this.collectionItemList[index].answerName.substr(
  340. this.collectionItemList[index].answerName.indexOf('.'),
  341. 3
  342. )
  343. );
  344. }
  345. }
  346. },
  347. zSelectVal(value) {
  348. console.log(value);
  349. var collectionAnswerlisd = this.collectionAnswerlisd;
  350. if (collectionAnswerlisd.length > 0) {
  351. var num = 0;
  352. for (var a = 0; a < collectionAnswerlisd.length; a++) {
  353. if (collectionAnswerlisd[a].id == value.id) {
  354. collectionAnswerlisd[a] = value;
  355. num = 0;
  356. } else {
  357. num = 1;
  358. }
  359. }
  360. if (num > 0) {
  361. collectionAnswerlisd.push(value);
  362. }
  363. } else {
  364. collectionAnswerlisd.push(value);
  365. }
  366. this.collectionAnswerlisd = collectionAnswerlisd;
  367. },
  368. imgClick(val, index) {
  369. this.collectionId = val.collectionId + '';
  370. this.indeximg = index;
  371. this.show = true;
  372. },
  373. newimgarr1() {
  374. this.$forceUpdate();
  375. },
  376. dateFn(val) {
  377. return val.slice(0, 4) + '-' + val.slice(4, 6) + '-' + val.slice(6, 8);
  378. },
  379. onLoad() { },
  380. onSubmit() {
  381. for (var c = 0; c < this.collectionAnswerlisd.length; c++) {
  382. for (var b = 0; b < this.collectionItemList.length; b++) {
  383. if (this.collectionAnswerlisd[c].id == this.collectionItemList[b].customId) {
  384. this.collectionItemList[b].customOptionList = this.collectionAnswerlisd[c].value;
  385. }
  386. }
  387. }
  388. if (this.flagclick) {
  389. this.flagclick = false;
  390. this.timer = null;
  391. this.timer = setTimeout(() => {
  392. this.flagclick = true;
  393. }, 2000);
  394. insertCustomAnswer(this.collectionItemList).then((res) => {
  395. if (res.code == 200) {
  396. this.$router.go(-1);
  397. }
  398. });
  399. }
  400. },
  401. setCollectionItemLists() {
  402. this.collectionItemList = [];
  403. this.collectionAnswerlisd = [];
  404. this.collectionItemList = JSON.parse(JSON.stringify(this.collectionItemLists));
  405. for (var q = 0; q < this.collectionItemList.length; q++) {
  406. // this.collectionItemList[q].answerName = undefined;
  407. // 公司
  408. // if (
  409. // (this.collectionItemList[q].answerType == 'gs' ||
  410. // this.collectionItemList[q].answerType == 'dq' ||
  411. // this.collectionItemList[q].answerType == 'xsb') &&
  412. // this.activaFlag
  413. // ) {
  414. // this.activaFlag = false;
  415. // if (this.collectionItemList[q].answerType == 'xsb') {
  416. // this.getDeptsBy(this.collectionItemList[q].answerName);
  417. // this.getDeptInfo(
  418. // 'dept',
  419. // this.collectionItemList[q].answerType,
  420. // this.collectionItemList[q].answerName
  421. // );
  422. // } else {
  423. // this.getDeptInfo(
  424. // 'dept',
  425. // this.collectionItemList[q].answerType,
  426. // this.collectionItemList[q].answerName
  427. // );
  428. // }
  429. // }
  430. // 单选
  431. if (this.collectionItemList[q].answerType == 'dx') {
  432. let findCustom = this.collectionItemList[q].customOptionList.find((item) => item.checked);
  433. if (findCustom) {
  434. this.collectionItemList[q].answerValue = findCustom.customOptionId + '';
  435. }
  436. }
  437. // 多选
  438. if (this.collectionItemList[q].answerType == 'duox') {
  439. let findCustom = [];
  440. this.collectionItemList[q].customOptionList.forEach((item) => {
  441. if (item.checked) {
  442. findCustom.push(item.customOptionId + '');
  443. }
  444. });
  445. if (findCustom) {
  446. this.collectionItemList[q].answerValue = findCustom.join(',');
  447. }
  448. }
  449. // 照片
  450. if (
  451. this.collectionItemList[q].answerType == 'zp' &&
  452. this.collectionItemList[q].fileInfoList
  453. ) {
  454. let fileIdList = [];
  455. this.collectionItemList[q].fileInfoList.forEach((item) => {
  456. fileIdList.push(item.id);
  457. });
  458. this.collectionItemList[q].fileIdList = fileIdList;
  459. }
  460. // 照片
  461. if (
  462. this.collectionItemList[q].answerType == 'jxs' &&
  463. this.collectionItemList[q].chainList
  464. ) {
  465. // let fileIdList = [];
  466. // this.collectionItemList[q].fileInfoList.forEach((item) => {
  467. // fileIdList.push(item.id);
  468. // });
  469. this.jxsList = this.collectionItemList[q].chainList;
  470. }
  471. }
  472. },
  473. getThreeDaysAgo() {
  474. let myDate = new Date();
  475. let lw = new Date(myDate - 1000 * 60 * 60 * 24 * 14); //最后一个数字30可改,30天的意思
  476. let lastY = lw.getFullYear();
  477. let lastM = lw.getMonth() + 1;
  478. let lastD = lw.getDate();
  479. let startData =
  480. lastY + '-' + (lastM < 10 ? '0' + lastM : lastM) + '-' + (lastD < 10 ? '0' + lastD : lastD); //三十天之前日期
  481. return startData;
  482. },
  483. GetPreMonthDay(date, monthNum, type) {
  484. var dateArr = date.split('-');
  485. var year = dateArr[0]; //获取当前日期的年份
  486. var month = dateArr[1]; //获取当前日期的月份
  487. var day = dateArr[2]; //获取当前日期的日
  488. var days = new Date(year, month, 0);
  489. days = days.getDate(); //获取当前日期中月的天数
  490. var year2 = year;
  491. var month2 = parseInt(month) - monthNum;
  492. if (month2 <= 0) {
  493. var absM = Math.abs(month2);
  494. year2 = parseInt(year2) - Math.ceil(absM / 12 == 0 ? 1 : parseInt(absM) / 12);
  495. month2 = 12 - (absM % 12);
  496. }
  497. var day2 = day;
  498. var days2 = new Date(year2, month2, 0);
  499. days2 = days2.getDate();
  500. if (day2 > days2) {
  501. day2 = days2;
  502. }
  503. if (month2 < 10) {
  504. month2 = '0' + month2;
  505. }
  506. var t2 = '';
  507. if (monthNum > 0) {
  508. t2 = year2 + '-' + month2 + '-01';
  509. } else {
  510. if (type == 'end') {
  511. var Months = new Date().getMonth() + 1;
  512. var days111 = new Date().getDate();
  513. if (Months < 10) {
  514. Months = '0' + Months;
  515. }
  516. if (days111 < 10) {
  517. days111 = '0' + days111;
  518. }
  519. if (parseInt(month2) >= new Date().getMonth() + 1) {
  520. t2 = year2 + '-' + Months + '-' + days111;
  521. } else {
  522. var daysd = this.getMonthDays(year2, month2);
  523. t2 = year2 + '-' + month2 + '-' + daysd;
  524. }
  525. } else {
  526. t2 = year2 + '-' + month2 + '-' + day2;
  527. }
  528. }
  529. return t2;
  530. },
  531. getMonthDays(year, month) {
  532. var stratDate = new Date(year, month - 1, 1),
  533. endData = new Date(year, month, 1);
  534. var days = (endData - stratDate) / (1000 * 60 * 60 * 24);
  535. return days;
  536. },
  537. getDeptInfo(type, grade, answerName) {
  538. this.deptForm.type = type;
  539. if (grade == 'dq') {
  540. this.deptForm.parentId = this.companyCode;
  541. } else if (grade == 'xsb') {
  542. this.deptForm.parentId = this.regionCode;
  543. } else {
  544. this.deptForm.type = '';
  545. this.deptForm.parentId = '';
  546. }
  547. getSummaryMobileDeptInfo(this.deptForm).then((res) => {
  548. if (grade == 'dq') {
  549. if (res.data.region != null) {
  550. this.regionList = res.data.region;
  551. if (answerName) {
  552. let findCompany = this.companyList.find((item) => item.deptName == answerName);
  553. // this.onSalesRegionConfirm(findCompany);
  554. } else {
  555. this.onSalesRegionConfirm(this.regionList[0]);
  556. }
  557. }
  558. } else if (grade == 'xsb') {
  559. if (res.data.dept != null) {
  560. this.deptList = res.data.dept;
  561. if (answerName) {
  562. let findCompany = this.regionList.find((item) => item.deptName == answerName);
  563. // this.onSalesDepartmentConfirm(findCompany);
  564. } else {
  565. this.onSalesDepartmentConfirm(this.deptList[0]);
  566. }
  567. }
  568. } else if (grade == 'gs') {
  569. this.companyList = res.data.company;
  570. if (answerName) {
  571. let findCompany = this.companyList.find((item) => item.deptName == answerName);
  572. // this.onregionConfirm(findCompany);
  573. } else {
  574. this.onregionConfirm(this.companyList[0]);
  575. }
  576. if (res.data.dept != null) {
  577. this.deptList = res.data.dept;
  578. }
  579. if (res.data.region != null) {
  580. this.regionList = res.data.region;
  581. }
  582. }
  583. });
  584. },
  585. getDeptsBy(answerName) {
  586. getDeptsByUser().then((res) => {
  587. if (res.data && res.code == 200) {
  588. let arr = [];
  589. res.data.forEach((val) => {
  590. arr.push({
  591. ancestors: val.ancestors || '',
  592. deptCode: val.deptCode || '',
  593. deptId: val.deptId || '',
  594. deptLevel: val.deptLevel || '',
  595. deptName: val.deptName || '',
  596. parentId: val.parentId || '',
  597. });
  598. });
  599. this.deptList = arr;
  600. if (answerName) {
  601. let findCompany = this.regionList.find((item) => item.deptCode == answerName);
  602. // this.onSalesDepartmentConfirm(findCompany);
  603. } else {
  604. this.onSalesDepartmentConfirm(this.deptList[0]);
  605. }
  606. }
  607. });
  608. },
  609. dailyFn(row) {
  610. if (row.status != '0') {
  611. if (row.status == -1) {
  612. var dayTime = row.showDate;
  613. var times = new Date(
  614. dayTime.slice(0, 4) + '-' + dayTime.slice(4, 6) + '-' + dayTime.slice(6, 8)
  615. ).getTime();
  616. var time = new Date('2022-08-25').getTime();
  617. if (times < time) {
  618. this.$dialog.alert({
  619. title: '系统提示',
  620. message: '非常抱歉,8月25日前历史报告数据不存在',
  621. });
  622. } else {
  623. this.$router.push({
  624. path: '/weeklyHistoricalDetils',
  625. query: { reportId: row.id },
  626. });
  627. }
  628. } else {
  629. this.$router.push({
  630. path: '/weeklyHistoricalDetils',
  631. query: { reportId: row.id },
  632. });
  633. }
  634. }
  635. },
  636. regionClick(val) {
  637. // if(this.powerGrade>4){
  638. this.index = val;
  639. this.RegionShow = true;
  640. // }
  641. },
  642. SalesRegionClick(val) {
  643. this.index = val;
  644. this.SalesRegionShow = true;
  645. },
  646. SalesDepartmentClick(val) {
  647. this.index = val;
  648. this.SalesDepartmentShow = true;
  649. },
  650. StaffClick() {
  651. this.StaffShow = true;
  652. },
  653. StartTimeClick() {
  654. this.StartTimeShow = true;
  655. },
  656. EndTimeClick() {
  657. this.EndTimeShow = true;
  658. },
  659. onSalesRegionConfirm(val) {
  660. this.SalesRegionShow = false;
  661. this.regionCode = val.deptId;
  662. for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  663. if (this.collectionItemList[k1].answerType == 'xsb') {
  664. this.collectionItemList[k1].answerName = '';
  665. this.collectionItemList[k1].answerValue = '';
  666. }
  667. if (this.collectionItemList[k1].answerType == 'dq') {
  668. this.collectionItemList[k1].answerName = val.deptName;
  669. this.collectionItemList[k1].answerValue = val.deptCode;
  670. }
  671. if (this.collectionItemList[k1].answerType == 'xsb' && val.deptId != '') {
  672. this.getDeptInfo('dept', 'xsb');
  673. }
  674. }
  675. },
  676. onregionConfirm(val) {
  677. this.RegionShow = false;
  678. this.companyCode = val.deptId;
  679. for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  680. if (this.collectionItemList[k1].answerType == 'xsb') {
  681. this.collectionItemList[k1].answerName = '';
  682. this.collectionItemList[k1].answerValue = '';
  683. }
  684. if (this.collectionItemList[k1].answerType == 'xsb') {
  685. this.collectionItemList[k1].answerName = '';
  686. this.collectionItemList[k1].answerValue = '';
  687. }
  688. if (this.collectionItemList[k1].answerType == 'gs') {
  689. this.collectionItemList[k1].answerName = val.deptName;
  690. this.collectionItemList[k1].answerValue = val.deptCode;
  691. }
  692. if (this.collectionItemList[k1].answerType == 'dq') {
  693. this.getDeptInfo('dept', 'dq');
  694. }
  695. }
  696. },
  697. onSalesDepartmentConfirm(val) {
  698. this.SalesDepartmentShow = false;
  699. for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  700. if (this.collectionItemList[k1].answerType == 'xsb') {
  701. this.collectionItemList[k1].answerName = val.deptName;
  702. this.collectionItemList[k1].answerValue = val.deptCode;
  703. }
  704. }
  705. },
  706. onStartTimeConfirm(val) {
  707. this.formData.startTime = this.parseTime(new Date(val), '{y}-{m}-{d}') + '';
  708. this.StartTimeShow = false;
  709. this.endminDate = new Date(val);
  710. this.endmaxDate = new Date(this.GetPreMonthDay(this.formData.startTime, -2, 'end'));
  711. if (
  712. new Date(this.formData.startTime).getTime() > new Date(this.formData.endTime).getTime() ||
  713. new Date(this.endmaxDate).getTime() < new Date(this.formData.endTime).getTime()
  714. ) {
  715. this.formData.endTime = this.parseTime(new Date(val), '{y}-{m}-{d}') + '';
  716. this.endcurrentDate = this.GetPreMonthDay(this.formData.startTime, -2);
  717. }
  718. this.list = [];
  719. this.formData.pageNum = 1;
  720. },
  721. onEndTimeConfirm(val) {
  722. this.formData.endTime = this.parseTime(new Date(val), '{y}-{m}-{d}');
  723. this.strtmaxDate = new Date(val);
  724. if (new Date(this.formData.startTime).getTime() > new Date(this.formData.endTime).getTime()) {
  725. this.formData.startTime = this.formData.endTime;
  726. }
  727. this.list = [];
  728. this.formData.pageNum = 1;
  729. this.EndTimeShow = false;
  730. },
  731. // 添加经销商或者门店
  732. addJXSorMD(val,index) {
  733. this.selectIndex = index;
  734. let answerType = val.answerType;
  735. let dataList = [];
  736. if (answerType == 'jxs') {
  737. dataList = val.chainList ? val.chainList : [];
  738. } else if (answerType == 'md') {
  739. dataList = val.storeList ? val.storeList : [];
  740. }
  741. const isExceedLimit = dataList.length >= val.maxValue;
  742. if (val.maxValue !== null && isExceedLimit) {
  743. this.$toast('超过最大限制!');
  744. } else {
  745. this.agentValue = '';
  746. if (answerType == 'jxs') {
  747. this.moreTypeShow = true;
  748. this.getChainsList();
  749. } else if (answerType == 'md') {
  750. this.storeTypeShow = true;
  751. this.storeType = val.storeType;
  752. this.getStoresList();
  753. }
  754. }
  755. },
  756. // 删除经销商或者门店
  757. closeJXSorMD(item, index) {
  758. if (item.answerType == 'jxs') {
  759. item.chainList.splice(index, 1);
  760. } else if (item.answerType == 'md') {
  761. item.storeList.splice(index, 1);
  762. }
  763. },
  764. getChainsList(value = '') {
  765. this.chainsData = [];
  766. chainsList({
  767. chainCode: '', // string 经销商编码
  768. chainName: value, // string 经销商名称
  769. limit: 100,
  770. })
  771. .then((res) => {
  772. if (res.code == 200 && res.rows) {
  773. this.chainsData = res.rows;
  774. } else {
  775. this.chainsData = [];
  776. }
  777. })
  778. .catch(() => {
  779. this.chainsData = [];
  780. });
  781. },
  782. getStoresList(value = '') {
  783. this.storesData = [];
  784. storesList({
  785. storeCategoryList: this.storeType ? this.storeType.split(",") : [], // 门店类型数组
  786. storeName: value, // 门店名称或者编号搜索,模糊搜索
  787. pageNum: 1, // int 页码
  788. PageSize: 100 // 每页数
  789. })
  790. .then((res) => {
  791. if (res.code == 200 && res.rows) {
  792. this.storesData = res.rows;
  793. } else {
  794. this.storesData = [];
  795. }
  796. })
  797. .catch(() => {
  798. this.storesData = [];
  799. });
  800. },
  801. onConfirmChainsList(value) {
  802. if (value && value.chainName != undefined) {
  803. let JXSSataList = this.collectionItemList.find((item,index) => item.answerType == 'jxs' && index == this.selectIndex);
  804. if (!JXSSataList.chainList) {
  805. JXSSataList.chainList = [];
  806. }
  807. let isFlag = JXSSataList.chainList.find((val) => val.chainCode == value.chainCode);
  808. if (!isFlag) {
  809. JXSSataList.chainList.push({
  810. chainName: value.chainName,
  811. chainCode: value.chainCode,
  812. });
  813. this.moreTypeShow = false;
  814. } else {
  815. this.$toast('当前经销商已添加,不能重复添加!');
  816. }
  817. }
  818. },
  819. onConfirmStoresList(value) {
  820. if (value && value.storeName != undefined) {
  821. let MDSataList = this.collectionItemList.find((item,index) => item.answerType == 'md' && index == this.selectIndex);
  822. if (!MDSataList.storeList) {
  823. MDSataList.storeList = [];
  824. }
  825. let isFlag = MDSataList.storeList.find((val) => val.storeCode == value.storeCode);
  826. if (!isFlag) {
  827. MDSataList.storeList.push({
  828. storeName: value.storeName,
  829. storeCode: value.storeCode,
  830. });
  831. this.storeTypeShow = false;
  832. } else {
  833. this.$toast('当前门店已添加,不能重复添加!');
  834. }
  835. }
  836. },
  837. },
  838. };
  839. </script>
  840. <style scoped lang="scss">
  841. .componVisitSummary {
  842. .van-f-red {
  843. color: red;
  844. width: 8px;
  845. display: inline-block;
  846. line-height: 26px;
  847. }
  848. .formLabel {
  849. margin: 0 16px;
  850. border-bottom: 1px solid #f1f1f1;
  851. }
  852. .formLabel .van-cell {
  853. padding: 10px 0;
  854. }
  855. .formLabel .van-cell::after {
  856. border: 0;
  857. }
  858. .formLabel .van-field {
  859. border: 1px solid #f1f1f1;
  860. padding: 6px;
  861. width: 100%;
  862. border-radius: 4px;
  863. overflow: hidden;
  864. }
  865. .formLabel .van-field__control {
  866. padding: 0 10px;
  867. }
  868. .formLabel .formLabeltitle {
  869. position: absolute;
  870. top: 8px;
  871. }
  872. .lineGrey {
  873. height: 10px;
  874. width: 100%;
  875. background: #f1f1f1;
  876. }
  877. .z-checkbox .van-radio {
  878. padding: 6px 0;
  879. }
  880. .z-cell .van-cell__title {
  881. font-size: 16px;
  882. }
  883. .van-form {
  884. background-color: white;
  885. }
  886. }
  887. </style>
  888. <style lang="scss">
  889. .jxsBox {
  890. .jxsContent {
  891. margin-bottom: 10px;
  892. .item {
  893. padding: 5px;
  894. background: #e9e9e9;
  895. margin: 5px 0;
  896. .el-popover__reference-wrapper {
  897. display: flex;
  898. justify-content: space-between;
  899. align-items: center;
  900. }
  901. .selectItem {
  902. flex: 1;
  903. white-space: nowrap;
  904. overflow: hidden;
  905. text-overflow: ellipsis;
  906. font-size: 14px;
  907. }
  908. }
  909. }
  910. .tips {
  911. text-align: right;
  912. }
  913. }
  914. .table-headermd {
  915. font-size: 12px;
  916. text-align: center;
  917. position: initial;
  918. width: 98% !important;
  919. margin: 0 auto;
  920. border-right: 0;
  921. }
  922. .table-headermd .el-table__header,
  923. .table-headermd .el-table__body {
  924. width: 100% !important;
  925. }
  926. /*.table-headermd col {width: 6.8rem;}*/
  927. .table-headermd col:nth-child(4) {
  928. width: 5.6rem;
  929. }
  930. .table-headermd col:nth-child(2),
  931. .table-headermd col:nth-child(3) {
  932. width: 4.6rem;
  933. }
  934. .table-headermd .van-cell {
  935. padding: 0 4px;
  936. height: 100%;
  937. }
  938. .table-headermd th.el-table__cell>.cell {
  939. padding: 0 4px;
  940. text-align: center;
  941. }
  942. .table-headermd th.el-table__cell:first-child>.cell {
  943. text-align: left;
  944. }
  945. .table-headermd th.el-table__cell {
  946. background-color: #1989fa;
  947. color: #fff;
  948. }
  949. .table-headermd .el-table__cell {
  950. padding: 4px 0;
  951. }
  952. .table-headermd.el-table .cell {
  953. padding: 0;
  954. }
  955. .table-headermd .tipTitle {
  956. overflow: hidden;
  957. text-overflow: ellipsis;
  958. display: -webkit-box;
  959. -webkit-box-orient: vertical;
  960. -webkit-line-clamp: 2;
  961. }
  962. .table-headermd::before {
  963. height: 0;
  964. }
  965. .xing {
  966. color: red;
  967. padding-left: 4px;
  968. }
  969. .formLabel .van-radio__label,
  970. .formLabel .van-checkbox__label {
  971. font-size: 1.4rem;
  972. }
  973. .table-headermd .cell,
  974. .el-table--border .el-table__cell:first-child .cell {
  975. padding: 0 4px;
  976. }
  977. .van-dialog__confirm,
  978. .van-dialog__confirm:active {
  979. color: #1989fa;
  980. }
  981. .navBarTOP {
  982. position: fixed;
  983. width: 100%;
  984. z-index: 2;
  985. top: 0;
  986. }
  987. .isTableMust {
  988. padding: 4px;
  989. color: #999;
  990. margin: 0;
  991. margin-top: -10px;
  992. }
  993. </style>