applyDialog.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. return this.selectionArr.some(
  112. (item) => item.ActivityTypeName == "公司调研电话会" || item.ActivityTypeName == "专家电话会" || item.ActivityTypeName == "分析师电话会" || item.IsYidongConduct == 1
  113. );
  114. }
  115. },
  116. isShowSummary() {
  117. return (this.addDialogType == "新增外呼人员" || this.addDialogType == "新增报名") && !this.selectionArr.some((item) => item.ActivityTypeName == "公司调研电话会" && item.LimitPeopleNum !== 0);
  118. },
  119. },
  120. created() {},
  121. mounted() {},
  122. methods: {
  123. async confirmPerson() {
  124. let addSignuUser = this.addSignuUser();
  125. this.measurement();
  126. const is = this.dynamicItem.some((item) => item.isShow == true);
  127. if (is) return this.$message.error("姓名有误");
  128. if (!this.userId) return this.$message.error("请输入姓名!");
  129. const res =
  130. (this.isType && this.addDialogType != "新增预约纪要") || this.signUpAdd == "报名" || this.signUpAdd == "易董" || this.signUpAdd == "c类"
  131. ? await raiInterface.activitySignupAddSignuUser({
  132. ActivityIds: this.selectList,
  133. List: addSignuUser,
  134. })
  135. : this.signUpAdd == "专项"
  136. ? await raiSpecial.addUserSpecial({
  137. ActivityIds: this.selectList,
  138. List: addSignuUser,
  139. })
  140. : this.addDialogType == "新增预约纪要"
  141. ? await raiInterface.activityAddSummaryUser({
  142. ActivityIds: this.selectList,
  143. UserIds: this.userId,
  144. })
  145. : await raiInterface.activitySignupAddUser({
  146. ActivityIds: this.selectList,
  147. List: addSignuUser,
  148. });
  149. if (res.Ret === 200) {
  150. this.$message.success("添加成功");
  151. this.$parent.getsDataList();
  152. }
  153. this.userId = "";
  154. this.userTyep = [];
  155. (this.dynamicItem = [{ name: "", isShow: false, radio: "1", checked: false }]), this.$emit("update:addDialogVisible", false);
  156. },
  157. addSignuUser() {
  158. let arr = [];
  159. this.dynamicItem.forEach((item) => {
  160. if (item.name) {
  161. arr.push({
  162. IsAppointment: item.checked ? 1 : 0,
  163. UserId: item.id,
  164. SignupType: this.isType ? +item.radio : 0,
  165. });
  166. }
  167. });
  168. return arr;
  169. },
  170. // 添加数组
  171. addItem() {
  172. if (this.signUpAdd == "报名" && this.minimumSummation == this.dynamicItem.length) return this.$message.warning(`所选活动最多还能添加${this.minimumSummation}人`);
  173. this.dynamicItem.push({
  174. name: "",
  175. isShow: false,
  176. radio: "1",
  177. checked: false,
  178. });
  179. },
  180. // 删除数组的某一项
  181. deleteItem(item, index) {
  182. this.dynamicItem.splice(index, 1);
  183. },
  184. /* 获取客户名称 */
  185. getCompany(query) {
  186. if (query.includes(",")) return;
  187. if (query) {
  188. raiInterface
  189. .activitySignupUserList({
  190. KeyWord: query,
  191. })
  192. .then((res) => {
  193. if (res.Ret === 200) {
  194. let arr = [];
  195. res.Data.List &&
  196. res.Data.List.forEach((item) => {
  197. let obj = {
  198. ...item,
  199. value: item.RealName + " , " + item.Mobile + " , " + item.CompanyName,
  200. };
  201. arr.push(obj);
  202. });
  203. this.companyList = arr;
  204. }
  205. });
  206. } else {
  207. this.companyList = [];
  208. }
  209. },
  210. callbackHandle(data, cb) {
  211. let results = data
  212. ? this.companyList.filter((item) => {
  213. return item.value.includes(data);
  214. })
  215. : this.companyList;
  216. clearTimeout(this.timeout);
  217. this.timeout = setTimeout(() => {
  218. cb(results);
  219. }, 300);
  220. if (results.length == 0) {
  221. this.warningIsShow = true;
  222. } else {
  223. this.warningIsShow = false;
  224. }
  225. },
  226. //退出弹框
  227. handleClose() {
  228. this.userId = "";
  229. this.userTyep = [];
  230. this.dynamicItem = [{ name: "", isShow: false, radio: "1", checked: false }];
  231. this.$parent.addDialogVisible = false;
  232. },
  233. //失去焦点
  234. focusCompany(name) {
  235. if ((name.length && this.companyList.length == 0) || this.warningIsShow) {
  236. this.dynamicItem.forEach((item) => {
  237. if (item.name == name) {
  238. item.isShow = true;
  239. }
  240. });
  241. } else {
  242. this.dynamicItem.forEach((item) => {
  243. if (item.name == name) {
  244. item.isShow = false;
  245. }
  246. });
  247. }
  248. },
  249. //联想选择后
  250. selectCompany(val, index) {
  251. this.companyList.forEach((item) => {
  252. if (item.value == val.name) {
  253. this.dynamicItem.splice(index, 1, { name: val.name, isShow: false, radio: val.radio, id: item.UserId, checked: this.dynamicItem[index].checked });
  254. }
  255. });
  256. },
  257. //最后的确定 遍历
  258. measurement() {
  259. const arr = [];
  260. const userIds = [];
  261. this.dynamicItem.forEach((item) => {
  262. if (item.name) {
  263. let obj = {
  264. Uid: item.id,
  265. Type: item.radio,
  266. };
  267. userIds.push(item.id);
  268. arr.push(obj);
  269. }
  270. });
  271. this.userId = userIds.length ? userIds.join(",") : "";
  272. this.userTyep = JSON.stringify(arr);
  273. },
  274. },
  275. };
  276. </script>
  277. <style lang="scss">
  278. .container-applydialog {
  279. .container-custom {
  280. width: 700px;
  281. }
  282. .container-applydial {
  283. width: 900px;
  284. }
  285. .inline {
  286. margin-bottom: 20px;
  287. width: 100%;
  288. .inline-input {
  289. width: 392px !important;
  290. }
  291. p {
  292. padding-top: 5px;
  293. font-size: 14px;
  294. font-family: PingFang SC;
  295. font-weight: 500;
  296. line-height: 20px;
  297. color: #ef5858;
  298. opacity: 1;
  299. }
  300. }
  301. .inline-content {
  302. padding-right: 20px;
  303. display: flex;
  304. justify-content: space-between;
  305. align-items: center;
  306. img {
  307. width: 14px;
  308. height: 14px;
  309. }
  310. }
  311. .defaultyi {
  312. display: none !important;
  313. }
  314. .el-input {
  315. width: 392px !important;
  316. }
  317. .add-box {
  318. display: flex;
  319. align-items: center;
  320. color: #5882ef;
  321. img {
  322. width: 16px;
  323. height: 16px;
  324. margin-right: 10px;
  325. }
  326. }
  327. .radio-content {
  328. display: flex;
  329. justify-content: space-between;
  330. margin: 0 30px;
  331. }
  332. }
  333. </style>