applyDialog.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <div class="container-applydialog">
  3. <el-dialog
  4. v-dialogDrag
  5. :close-on-click-modal="false"
  6. :modal-append-to-body="false"
  7. center
  8. :visible.sync="addDialogVisible"
  9. :customClass="[isType && addDialogType !== '新增预约纪要' ? 'container-applydial' : 'container-custom']"
  10. :before-close="handleClose"
  11. >
  12. <div slot="title" style="display: flex; align-items: center">
  13. <img :src="$icons.add" style="color: #fff; width: 16px; height: 16px; margin-right: 5px" />
  14. <span style="font-size: 16px">{{ addDialogType }}</span>
  15. </div>
  16. <div class="inline" v-for="(item, index) in dynamicItem" :key="index">
  17. <div class="inline-content">
  18. <el-autocomplete
  19. class="inline-input"
  20. v-model="item.name"
  21. :fetch-suggestions="callbackHandle"
  22. placeholder="请输入姓名"
  23. @input="getCompany(item.name)"
  24. @select="selectCompany(item, index)"
  25. @blur="focusCompany(item.name)"
  26. :trigger-on-focus="false"
  27. clearable
  28. ></el-autocomplete>
  29. <template v-if="selectionArr && selectionArr.length && selectionArr[0].ActivityTypeName == '公司调研电话会'">
  30. <div class="radio-content" v-if="selectionArr[0].IsResearchPoints != 1">
  31. <el-radio v-model="item.radio" label="1">预约外呼</el-radio>
  32. <el-radio v-model="item.radio" label="2" v-if="selectionArr[0].LimitPeopleNum > 0">自主拨入</el-radio>
  33. </div>
  34. <div style="margin: 0 20px" v-if="selectionArr[0].IsCanAppointmentMinutes > 0">
  35. <el-checkbox v-model="item.checked">同时预约纪要</el-checkbox>
  36. </div>
  37. </template>
  38. <template v-else>
  39. <div v-if="isType && addDialogType !== '新增预约纪要'" class="radio-content">
  40. <el-radio v-model="item.radio" label="1">预约外呼</el-radio>
  41. <el-radio v-model="item.radio" label="2">自主拨入</el-radio>
  42. </div>
  43. <div style="margin: 0 20px" v-if="isShowSummary && signUpAdd !== '易董' && signUpAdd !== '专项'">
  44. <el-checkbox v-model="item.checked">同时预约纪要</el-checkbox>
  45. </div>
  46. </template>
  47. <div style="width: 20px"><img @click="deleteItem(item, index)" src="~@/assets/img/icons/delete-Item.png" :class="index == 0 ? 'defaultyi' : ''" alt="" /></div>
  48. </div>
  49. <p v-if="item.isShow">系统中无此人,请先将其添加到对应公司的联系人列表下</p>
  50. </div>
  51. <div class="add-box">
  52. <img @click="addItem" :src="$icons.addblue" alt="" />
  53. <span @click="addItem">添加</span>
  54. </div>
  55. <span slot="footer" class="dialog-footer">
  56. <el-button type="primary" @click="confirmPerson">确定</el-button>
  57. <el-button @click="handleClose">取消</el-button>
  58. </span>
  59. </el-dialog>
  60. </div>
  61. </template>
  62. <script>
  63. import { raiInterface, raiSpecial } from "@/api/api.js";
  64. export default {
  65. name: "",
  66. components: {},
  67. props: {
  68. addDialogVisible: {
  69. type: Boolean,
  70. default: false,
  71. },
  72. dialogVisibleId: {
  73. type: Number,
  74. },
  75. selectList: {
  76. type: String,
  77. },
  78. signUpAdd: {
  79. type: String,
  80. },
  81. minimumSummation: {
  82. type: Number,
  83. },
  84. tabsPitchonType: {
  85. type: Number,
  86. },
  87. selectionArr: {
  88. type: Array,
  89. required: true,
  90. default: [],
  91. },
  92. addDialogType: {
  93. type: String,
  94. required: true,
  95. },
  96. },
  97. data() {
  98. return {
  99. dynamicItem: [{ name: "", isShow: false, radio: "1", checked: false }],
  100. companyList: [], //客户名称的数组
  101. timeout: null, //
  102. isShow: "",
  103. warningIsShow: false,
  104. userId: "",
  105. userTyepa: [],
  106. };
  107. },
  108. computed: {
  109. isType() {
  110. if (this.selectionArr.length > 0) {
  111. console.log(this.selectionArr);
  112. return this.selectionArr.some(
  113. (item) => item.ActivityTypeName == "公司调研电话会" || item.ActivityTypeName == "专家电话会" || item.ActivityTypeName == "分析师电话会" || item.IsYidongConduct == 1
  114. );
  115. }
  116. },
  117. isShowSummary() {
  118. return (this.addDialogType == "新增外呼人员" || this.addDialogType == "新增报名") && !this.selectionArr.some((item) => item.ActivityTypeName == "公司调研电话会" && item.LimitPeopleNum !== 0);
  119. },
  120. },
  121. created() {},
  122. mounted() {},
  123. methods: {
  124. async confirmPerson() {
  125. let addSignuUser = this.addSignuUser();
  126. this.measurement();
  127. const is = this.dynamicItem.some((item) => item.isShow == true);
  128. if (is) return this.$message.error("姓名有误");
  129. if (!this.userId) return this.$message.error("请输入姓名!");
  130. const res =
  131. (this.isType && this.addDialogType != "新增预约纪要") || this.signUpAdd == "报名" || this.signUpAdd == "易董" || this.signUpAdd == "c类"
  132. ? await raiInterface.activitySignupAddSignuUser({
  133. ActivityIds: this.selectList,
  134. List: addSignuUser,
  135. })
  136. : this.signUpAdd == "专项"
  137. ? await raiSpecial.addUserSpecial({
  138. ActivityIds: this.selectList,
  139. List: addSignuUser,
  140. })
  141. : this.addDialogType == "新增预约纪要"
  142. ? await raiInterface.activityAddSummaryUser({
  143. ActivityIds: this.selectList,
  144. UserIds: this.userId,
  145. })
  146. : await raiInterface.activitySignupAddUser({
  147. ActivityIds: this.selectList,
  148. List: addSignuUser,
  149. });
  150. if (res.Ret === 200) {
  151. this.$message.success("添加成功");
  152. this.$parent.getsDataList();
  153. }
  154. this.userId = "";
  155. this.userTyep = [];
  156. (this.dynamicItem = [{ name: "", isShow: false, radio: "1", checked: false }]), this.$emit("update:addDialogVisible", false);
  157. },
  158. addSignuUser() {
  159. let arr = [];
  160. this.dynamicItem.forEach((item) => {
  161. if (item.name) {
  162. arr.push({
  163. IsAppointment: item.checked ? 1 : 0,
  164. UserId: item.id,
  165. SignupType: this.isType ? +item.radio : 0,
  166. });
  167. }
  168. });
  169. return arr;
  170. },
  171. // 添加数组
  172. addItem() {
  173. if (this.signUpAdd == "报名" && this.minimumSummation == this.dynamicItem.length) return this.$message.warning(`所选活动最多还能添加${this.minimumSummation}人`);
  174. this.dynamicItem.push({
  175. name: "",
  176. isShow: false,
  177. radio: "1",
  178. checked: false,
  179. });
  180. },
  181. // 删除数组的某一项
  182. deleteItem(item, index) {
  183. this.dynamicItem.splice(index, 1);
  184. },
  185. /* 获取客户名称 */
  186. getCompany(query) {
  187. if (query.includes(",")) return;
  188. if (query) {
  189. raiInterface
  190. .activitySignupUserList({
  191. KeyWord: query,
  192. })
  193. .then((res) => {
  194. if (res.Ret === 200) {
  195. let arr = [];
  196. res.Data.List &&
  197. res.Data.List.forEach((item) => {
  198. let obj = {
  199. ...item,
  200. value: item.RealName + " , " + item.Mobile + " , " + item.CompanyName,
  201. };
  202. arr.push(obj);
  203. });
  204. this.companyList = arr;
  205. }
  206. });
  207. } else {
  208. this.companyList = [];
  209. }
  210. },
  211. callbackHandle(data, cb) {
  212. let results = data
  213. ? this.companyList.filter((item) => {
  214. return item.value.includes(data);
  215. })
  216. : this.companyList;
  217. clearTimeout(this.timeout);
  218. this.timeout = setTimeout(() => {
  219. cb(results);
  220. }, 300);
  221. if (results.length == 0) {
  222. this.warningIsShow = true;
  223. } else {
  224. this.warningIsShow = false;
  225. }
  226. },
  227. //退出弹框
  228. handleClose() {
  229. this.userId = "";
  230. this.userTyep = [];
  231. this.dynamicItem = [{ name: "", isShow: false, radio: "1", checked: false }];
  232. this.$parent.addDialogVisible = false;
  233. },
  234. //失去焦点
  235. focusCompany(name) {
  236. if ((name.length && this.companyList.length == 0) || this.warningIsShow) {
  237. this.dynamicItem.forEach((item) => {
  238. if (item.name == name) {
  239. item.isShow = true;
  240. }
  241. });
  242. } else {
  243. this.dynamicItem.forEach((item) => {
  244. if (item.name == name) {
  245. item.isShow = false;
  246. }
  247. });
  248. }
  249. },
  250. //联想选择后
  251. selectCompany(val, index) {
  252. this.companyList.forEach((item) => {
  253. if (item.value == val.name) {
  254. this.dynamicItem.splice(index, 1, { name: val.name, isShow: false, radio: val.radio, id: item.UserId, checked: this.dynamicItem[index].checked });
  255. }
  256. });
  257. },
  258. //最后的确定 遍历
  259. measurement() {
  260. const arr = [];
  261. const userIds = [];
  262. this.dynamicItem.forEach((item) => {
  263. if (item.name) {
  264. let obj = {
  265. Uid: item.id,
  266. Type: item.radio,
  267. };
  268. userIds.push(item.id);
  269. arr.push(obj);
  270. }
  271. });
  272. this.userId = userIds.length ? userIds.join(",") : "";
  273. this.userTyep = JSON.stringify(arr);
  274. },
  275. },
  276. };
  277. </script>
  278. <style lang="scss">
  279. .container-applydialog {
  280. .container-custom {
  281. width: 700px;
  282. }
  283. .container-applydial {
  284. width: 900px;
  285. }
  286. .inline {
  287. margin-bottom: 20px;
  288. width: 100%;
  289. .inline-input {
  290. width: 392px !important;
  291. }
  292. p {
  293. padding-top: 5px;
  294. font-size: 14px;
  295. font-family: PingFang SC;
  296. font-weight: 500;
  297. line-height: 20px;
  298. color: #ef5858;
  299. opacity: 1;
  300. }
  301. }
  302. .inline-content {
  303. padding-right: 20px;
  304. display: flex;
  305. justify-content: space-between;
  306. align-items: center;
  307. img {
  308. width: 14px;
  309. height: 14px;
  310. }
  311. }
  312. .defaultyi {
  313. display: none !important;
  314. }
  315. .el-input {
  316. width: 392px !important;
  317. }
  318. .add-box {
  319. display: flex;
  320. align-items: center;
  321. color: #5882ef;
  322. img {
  323. width: 16px;
  324. height: 16px;
  325. margin-right: 10px;
  326. }
  327. }
  328. .radio-content {
  329. display: flex;
  330. justify-content: space-between;
  331. margin: 0 30px;
  332. }
  333. }
  334. </style>