Time-limit-add.vue 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  1. <template>
  2. <div class="system-timeLimit-add-container">
  3. <el-dialog v-model="state.dialogVisible" width="60%" draggable title="新增时限">
  4. <el-form :model="state.ruleForm" ref="ruleFormRef" label-width="100px" scroll-to-error>
  5. <el-row :gutter="5">
  6. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
  7. <el-form-item label="配置名称" prop="timeLimitName" :rules="[{ required: true, message: '请填写配置名称', trigger: 'blur' }]">
  8. <el-input v-model="state.ruleForm.timeLimitName" placeholder="请填写配置名称" clearable max-length="50"></el-input>
  9. </el-form-item>
  10. </el-col>
  11. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
  12. <el-form-item label="业务名称" prop="workflowObj" :rules="[{ required: true, message: '请选择业务名称', trigger: 'change' }]">
  13. <el-select
  14. v-model="state.ruleForm.workflowObj"
  15. placeholder="请选择业务名称"
  16. style="width: calc(100% - 60px)"
  17. value-key="key"
  18. @change="
  19. (val) => {
  20. state.ruleForm.workflowCode = val.key;
  21. state.ruleForm.workflowName = val.value;
  22. }
  23. "
  24. >
  25. <el-option v-for="item in state.moduleOptions" :key="item.key" :label="item.value" :value="item" />
  26. </el-select>
  27. <el-tooltip placement="top-start" v-if="state.ruleForm.workflowCode === 'Order'">
  28. <SvgIcon name="ele-InfoFilled" size="24px" color="var(--el-color-primary)" class="ml15" />
  29. <template #content>
  30. 说明:时限计算优先级依次为指定优先级、组合、时限最短。<br />
  31. 若已配置指定参数优先级的,则先按指定的优先级计算办理期限;
  32. <br />无指定优先级的,默认按组合最短时限计算办理期限;<br />
  33. 无组合配置的,则默认按已配置的参数最短时限计算办理期限;未配置时限的参数,默认为无时限要求。
  34. </template>
  35. </el-tooltip>
  36. </el-form-item>
  37. </el-col>
  38. </el-row>
  39. </el-form>
  40. <el-collapse
  41. v-model="state.collapseArr"
  42. class="collapse-box mt20"
  43. style="border-top: none"
  44. v-loading="state.loading"
  45. v-if="state.ruleForm.workflowCode === 'Order'"
  46. >
  47. <p class="border-title mb10">参数信息</p>
  48. <!-- 参数多选 -->
  49. <div class="pl20 pr20">
  50. <el-checkbox-group v-model="state.parameterList" class="pd20">
  51. <el-row>
  52. <el-col v-for="(item, index) in state.baseData" :key="index" :xs="24" :sm="8" :md="8" :lg="6" :xl="4">
  53. <el-checkbox :label="item" @change="(val) => parameterChange(val, item)">{{ item.name }}</el-checkbox>
  54. </el-col>
  55. </el-row>
  56. </el-checkbox-group>
  57. <el-collapse-item name="1">
  58. <template #title>
  59. <p class="pl10">
  60. <b class="font14">已选参数</b>
  61. </p>
  62. </template>
  63. <div class="parameter pl20 pr20">
  64. <!-- 已选列表 -->
  65. <div class="mt20 parameter-choose">
  66. <el-row>
  67. <el-col v-for="(item, index) in state.paramArr" :key="index" :xs="24" :sm="8" :md="8" :lg="6" :xl="4">
  68. <div class="parameter-choose-one text-no-wrap" :class="{ active: item.active }" @click="chooseParameter(item)">
  69. {{ item.name }}<span v-if="item.paramValue.length">({{ item.paramValue.length }})</span>
  70. </div>
  71. </el-col>
  72. </el-row>
  73. </div>
  74. <!-- 参数表格 -->
  75. <el-table :data="state.currentParam.paramValue" class="mt20" v-if="state.currentParam">
  76. <el-table-column :label="state.currentParam.name" prop="paramTypeValue">
  77. <template #default="{ row }">
  78. <template v-if="state.currentParam.typeCode === 'HotPots'">
  79. <el-tree-select
  80. class="w100"
  81. v-model="row.paramTypeValue"
  82. filterable
  83. placeholder="请选择热点分类"
  84. :props="HotspotProps"
  85. lazy
  86. :load="load"
  87. node-key="id"
  88. check-strictly
  89. :render-after-expand="false"
  90. @node-click="
  91. (val, e) => {
  92. state.hotspotExternal = [];
  93. state.external = [];
  94. row.paramTypeName = val.hotSpotFullName;
  95. state.hotspotExternal = getParentId(e, state.external);
  96. row.hotParamParent = getParentId(e, state.external).join(',');
  97. }
  98. "
  99. :default-expanded-keys="state.hotspotExternal"
  100. />
  101. </template>
  102. <template v-else>
  103. <el-select
  104. v-model="row.paramTypeObj"
  105. :placeholder="'请选择' + state.currentParam.name"
  106. value-key="key"
  107. class="w100"
  108. @change="
  109. (val) => {
  110. row.paramTypeValue = val.key;
  111. row.paramTypeName = val.value;
  112. getSelectedParam();
  113. getEnableAcceptType();
  114. }
  115. "
  116. >
  117. <el-option v-for="item in state.selectArray" :key="item.key" :label="item.value" :value="item" :disabled="item.disabled" />
  118. </el-select>
  119. </template>
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="时限" prop="name">
  123. <template #default="{ row }">
  124. <el-input-number
  125. v-model="row.timeLimitValue"
  126. :min="1"
  127. @change="
  128. (val) => {
  129. getSelectedParam();
  130. getEnableAcceptType();
  131. if (row.timeLimitType !== 1) row.hour = val * 24;
  132. else row.hour = val;
  133. }
  134. "
  135. placeholder="请填写时限"
  136. class="w100"
  137. ></el-input-number>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="单位" prop="name">
  141. <template #default="{ row }">
  142. <el-select
  143. v-model="row.hourObj"
  144. placeholder="请选择单位"
  145. class="w100"
  146. value-key="key"
  147. @change="
  148. (val) => {
  149. row.timeLimitType = val.key;
  150. if (val.key !== 1) row.hour = row.timeLimitValue * 24;
  151. else row.hour = row.timeLimitValue;
  152. row.timeLimitTypeName = val.value;
  153. getSelectedParam();
  154. getEnableAcceptType();
  155. }
  156. "
  157. >
  158. <el-option v-for="item in state.timeType" :key="item.key" :label="item.value" :value="item" />
  159. </el-select>
  160. </template>
  161. </el-table-column>
  162. <el-table-column align="center" width="100">
  163. <template #header>
  164. <el-button type="primary" @click="handleAdd"> 新增 </el-button>
  165. </template>
  166. <template #default="scope">
  167. <el-button @click="handleDelete(scope.row, scope.$index)" type="danger" text>删除</el-button>
  168. </template>
  169. </el-table-column>
  170. </el-table>
  171. <div class="mt20"></div>
  172. </div>
  173. </el-collapse-item>
  174. <el-collapse-item name="2">
  175. <template #title>
  176. <p class="pl10">
  177. <b class="font14">已配置参数</b>
  178. </p>
  179. </template>
  180. <div class="parameter-stop pd20">
  181. <el-row>
  182. <el-col v-for="(item, index) in state.paramSelect" :key="index" :xs="24" :sm="8" :md="8" :lg="6" :xl="4" :title="item.name">
  183. <div class="parameter-stop-one text-no-wrap mb10" :class="{ active: item.active }" @click="selectParameter(item)">
  184. {{ item.name }}
  185. </div>
  186. </el-col>
  187. </el-row>
  188. </div>
  189. </el-collapse-item>
  190. <el-collapse-item name="3">
  191. <template #title>
  192. <p class="flex-center-align pl10">
  193. <b class="font14">指定优先级</b>
  194. <el-tooltip placement="top-start" content="选中已配置参数,可自定义优先级,参数越靠前优先级越高。" trigger="hover">
  195. <SvgIcon name="ele-QuestionFilled" size="16px" color="var(--el-color-info)" class="ml5"></SvgIcon>
  196. </el-tooltip>
  197. </p>
  198. </template>
  199. <div class="pd20">
  200. <draggable-list :list="state.priority" :force-fallback="true" animation="300" @end="onEnd" itemKey="id" class="parameter-sort">
  201. <template #item="item">
  202. <div class="parameter-sort-one" :title="item.element.timeLimitValue">
  203. <el-tag class="mr20"> {{ item.index + 1 }}. {{ item.element.name }} </el-tag>
  204. </div>
  205. </template>
  206. </draggable-list>
  207. </div>
  208. </el-collapse-item>
  209. </div>
  210. </el-collapse>
  211. <p class="border-title mb10 mt20" v-if="state.ruleForm.workflowCode === 'Order'">参数组合</p>
  212. <!-- 组合参数表格 -->
  213. <div class="pd20" v-if="state.ruleForm.workflowCode === 'Order'">
  214. <el-table :data="state.combination">
  215. <el-table-column label="组合名称" prop="combinationName">
  216. <template #default="{ row }">
  217. <el-input v-model="row.combinationName" placeholder="请填写组合名称" class="w100" max-length="30"></el-input>
  218. </template>
  219. </el-table-column>
  220. <el-table-column label="参数" prop="combinationDisplayParam">
  221. <template #default="{ row }">
  222. <div class="flex-center-align">
  223. <span class="omit text-no-wrap" :title="row.combinationDisplayParam">{{ row.combinationDisplayParam }}</span>
  224. <el-button class="ml3" text title="配置参数" type="primary" @click="chooseCombination(row)">
  225. <SvgIcon name="ele-Edit" size="16px" />
  226. </el-button>
  227. </div>
  228. </template>
  229. </el-table-column>
  230. <el-table-column label="时限" prop="timeLimitValue">
  231. <template #default="{ row }">
  232. <el-input-number
  233. v-model="row.timeLimitValue"
  234. :min="1"
  235. placeholder="请填写时限"
  236. class="w100"
  237. @change="
  238. (val) => {
  239. if (row.timeLimit !== 1) row.hour = val * 24;
  240. else row.hour = val;
  241. }
  242. "
  243. ></el-input-number>
  244. </template>
  245. </el-table-column>
  246. <el-table-column label="单位" prop="hourObj">
  247. <template #default="{ row }">
  248. <el-select
  249. v-model="row.hourObj"
  250. value-key="key"
  251. placeholder="请选择单位"
  252. class="w100"
  253. @change="
  254. (val) => {
  255. row.timeLimit = val.key;
  256. if (val.key !== 1) row.hour = row.timeLimitValue * 24;
  257. else row.hour = row.timeLimitValue;
  258. row.timeLimitTypeName = val.value;
  259. }
  260. "
  261. >
  262. <el-option v-for="item in state.timeType" :key="item.key" :label="item.value" :value="item" />
  263. </el-select>
  264. </template>
  265. </el-table-column>
  266. <el-table-column align="center" width="100">
  267. <template #header>
  268. <el-button type="primary" @click="combinationAdd"> 新增 </el-button>
  269. </template>
  270. <template #default="scope">
  271. <el-button @click="combinationDelete(scope.row, scope.$index)" type="danger" text>删除</el-button>
  272. </template>
  273. </el-table-column>
  274. </el-table>
  275. </div>
  276. <template #footer>
  277. <span class="dialog-footer">
  278. <el-button @click="onSubmit(ruleFormRef)" class="default-button">暂 存</el-button>
  279. <el-button type="primary" @click="onConfirm(ruleFormRef)">确 定</el-button>
  280. </span>
  281. </template>
  282. </el-dialog>
  283. <el-dialog v-model="state.paramDialog" width="700" draggable title="参数选择">
  284. <el-form :model="state.paramForm" ref="paramFormRef" label-width="100px">
  285. <el-row :gutter="5">
  286. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  287. <el-form-item label="受理类型" prop="acceptType" :rules="[{ required: false, message: '请选择受理类型', trigger: 'change' }]">
  288. <el-select
  289. v-model="state.paramForm.acceptType"
  290. placeholder="请选择受理类型"
  291. class="w100"
  292. value-key="key"
  293. clearable
  294. @clear="clearCombinationParam('AcceptType')"
  295. >
  296. <el-option v-for="item in state.result.acceptType" :key="item.key" :label="item.value" :value="item" />
  297. </el-select>
  298. </el-form-item>
  299. </el-col>
  300. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  301. <el-form-item label="热点分类" prop="hotspot" :rules="[{ required: false, message: '请选择热点分类', trigger: 'change' }]">
  302. <el-tree-select
  303. class="w100"
  304. v-model="state.paramForm.hotspot"
  305. filterable
  306. placeholder="请选择热点分类"
  307. :props="HotspotProps"
  308. lazy
  309. :load="load"
  310. node-key="id"
  311. check-strictly
  312. :render-after-expand="false"
  313. @node-click="getComHotspot"
  314. ref="hotspotComRef"
  315. :default-expanded-keys="state.hotspotExternalCom"
  316. clearable
  317. @clear="clearCombinationParam('HotPots')"
  318. />
  319. </el-form-item>
  320. </el-col>
  321. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  322. <el-form-item label="来源渠道" prop="sourceChannel" :rules="[{ required: false, message: '请选择来源渠道', trigger: 'change' }]">
  323. <el-select
  324. v-model="state.paramForm.sourceChannel"
  325. placeholder="请选择来源渠道"
  326. class="w100"
  327. value-key="key"
  328. filterable
  329. clearable
  330. @clear="clearCombinationParam('SourceChannel')"
  331. >
  332. <el-option v-for="item in state.result.sourceChannel" :key="item.key" :label="item.value" :value="item" />
  333. </el-select>
  334. </el-form-item>
  335. </el-col>
  336. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  337. <el-form-item label="来电人身份" prop="identityType" :rules="[{ required: false, message: '请选择来电人身份', trigger: 'change' }]">
  338. <el-select
  339. v-model="state.paramForm.identityType"
  340. placeholder="请选择来电人身份"
  341. class="w100"
  342. value-key="key"
  343. filterable
  344. clearable
  345. @clear="clearCombinationParam('IdentityType')"
  346. >
  347. <el-option v-for="item in state.result.identityType" :key="item.key" :label="item.value" :value="item" />
  348. </el-select>
  349. </el-form-item>
  350. </el-col>
  351. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  352. <el-form-item label="工单类型" prop="orderType" :rules="[{ required: false, message: '请选择工单类型', trigger: 'change' }]">
  353. <el-select
  354. v-model="state.paramForm.orderType"
  355. placeholder="请选择工单类型"
  356. class="w100"
  357. value-key="key"
  358. filterable
  359. clearable
  360. @clear="clearCombinationParam('OrderType')"
  361. >
  362. <el-option v-for="item in state.result.orderType" :key="item.key" :label="item.value" :value="item" />
  363. </el-select>
  364. </el-form-item>
  365. </el-col>
  366. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  367. <el-form-item label="证件类型" prop="certType" :rules="[{ required: false, message: '请选择证件类型类', trigger: 'change' }]">
  368. <el-select
  369. v-model="state.paramForm.certType"
  370. placeholder="请选择证件类型"
  371. class="w100"
  372. value-key="dicDataValue"
  373. filterable
  374. clearable
  375. @clear="clearCombinationParam('LicenceType')"
  376. >
  377. <el-option v-for="item in state.result.certType" :key="item.dicDataValue" :label="item.dicDataName" :value="item" />
  378. </el-select>
  379. </el-form-item>
  380. </el-col>
  381. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  382. <el-form-item label="紧急程度" prop="emergencyLevel" :rules="[{ required: false, message: '请选择紧急程度', trigger: 'change' }]">
  383. <el-select
  384. v-model="state.paramForm.emergencyLevel"
  385. placeholder="请选择紧急程度"
  386. class="w100"
  387. value-key="key"
  388. filterable
  389. clearable
  390. @clear="clearCombinationParam('EmergencyLevel')"
  391. >
  392. <el-option v-for="item in state.result.emergencyLevel" :key="item.key" :label="item.value" :value="item" />
  393. </el-select>
  394. </el-form-item>
  395. </el-col>
  396. <!-- <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  397. <el-form-item label="默认参数" prop="emergencyLevel" :rules="[{ required: false, message: '请选择默认参数', trigger: 'change' }]">
  398. <el-select v-model="state.paramForm.emergencyLevel" placeholder="请选择默认参数" class="w100" value-key="key" filterable clearable>
  399. <el-option v-for="item in state.result.emergencyLevel" :key="item.key" :label="item.value" :value="item" @clear="clearCombinationParam('EmergencyLevel')" />
  400. </el-select>
  401. </el-form-item>
  402. </el-col> -->
  403. </el-row>
  404. </el-form>
  405. <template #footer>
  406. <span class="dialog-footer">
  407. <el-button class="default-button" @click="state.paramDialog = false">取 消</el-button>
  408. <el-button type="primary" @click="onConfirmCom">确 定</el-button>
  409. </span>
  410. </template>
  411. </el-dialog>
  412. </div>
  413. </template>
  414. <script lang="ts" setup name="addTimeLimit">
  415. import { ref, reactive } from 'vue';
  416. import { ElMessage, ElMessageBox, FormInstance } from 'element-plus';
  417. import { guid } from '@/utils/tools';
  418. import { removeDuplicate } from '@/utils/arrayOperation';
  419. import other from '@/utils/other';
  420. import DraggableList from 'vuedraggable';
  421. import { hotSpotType } from '@/api/business/order';
  422. import { timeLimitAdd, timeLimitUpdate } from '@/api/system/timeLimit';
  423. // 定义子组件向父组件传值/事件
  424. const emit = defineEmits(['updateList', 'openDialog', 'closeDialog']);
  425. const paramTypeNameType: any = {
  426. AcceptType: '受理类型',
  427. HotPots: '热点分类',
  428. SourceChannel: '来源渠道',
  429. IdentityType: '来电人身份',
  430. OrderType: '工单类型',
  431. LicenceType: '证件类型',
  432. EmergencyLevel: '紧急程度',
  433. DefaultTime: '默认参数',
  434. };
  435. // 定义变量内容
  436. const ruleFormRef = ref<RefType>();
  437. const state = reactive<any>({
  438. ruleForm: {},
  439. paramForm: {},
  440. paramDialog: false,
  441. dialogVisible: false,
  442. baseData: [], // 基础数据
  443. parameterList: [], //选择基础数据
  444. paramArr: [], //参数列表信息
  445. currentParam: null as any, // 当前参数
  446. collapseArr: ['1', '2', '3', '4'], //展开列表
  447. result: {}, //所有基础数据
  448. timeType: [], // 单位
  449. moduleOptions: [], // 业务名称
  450. selectArray: [], // 可选数据
  451. paramSelect: [], // 已配置的数据 (可选择)
  452. priority: [], // 排序参数
  453. combination: [], // 组合
  454. hotspotExternal: [], // 热点分类展开
  455. external: [],
  456. hotspotExternalCom: [], // 组合热点分类展开
  457. externalCom: [],
  458. timeLimitId: null as any,
  459. });
  460. // 热点分类远程搜索
  461. const HotspotProps = {
  462. label: 'hotSpotFullName',
  463. children: 'children',
  464. isLeaf: 'isLeaf',
  465. };
  466. // 热点分类懒加载
  467. const load = async (node: any, resolve: any) => {
  468. if (node.isLeaf) return resolve([]);
  469. const res: any = await hotSpotType({ id: node.data.id ? node.data.id : '' });
  470. resolve(res.result);
  471. };
  472. // 递归查找父级Id
  473. const getParentId = (val: any, arr: string[]) => {
  474. if (val.data.parentId) {
  475. arr.push(val.data.parentId);
  476. getParentId(val.parent, arr);
  477. }
  478. return arr;
  479. };
  480. const resetState = () => {
  481. state.parameterList = [];
  482. state.paramArr = [];
  483. state.currentParam = null;
  484. state.selectArray = [];
  485. state.paramSelect = [];
  486. state.priority = [];
  487. state.combination = [];
  488. state.hotspotExternal = [];
  489. state.external = [];
  490. state.hotspotExternalCom = [];
  491. state.externalCom = [];
  492. };
  493. const openDialog = (baseData: any) => {
  494. state.ruleForm.workflowCode = '';
  495. const { baseData: stateBaseData = [], timeType = [], moduleOptions = [] } = baseData;
  496. state.result = baseData;
  497. state.baseData = stateBaseData; //基础数据
  498. state.timeType = timeType; //单位
  499. state.moduleOptions = moduleOptions; //业务名称
  500. resetState();
  501. ruleFormRef.value?.resetFields();
  502. state.dialogVisible = true;
  503. emit('openDialog');
  504. };
  505. // 关闭弹窗
  506. const closeDialog = () => {
  507. state.dialogVisible = false;
  508. emit('closeDialog');
  509. };
  510. // 选择参数
  511. const parameterChange = (value: string | number | boolean, item: any) => {
  512. let arr: any = other.deepClone(state.parameterList);
  513. state.paramArr = arr.map((v: any) => {
  514. let j = state.paramArr.find((j: any) => j.paramType === v.typeCode);
  515. if (j) {
  516. v.paramValue = j.paramValue;
  517. }
  518. return {
  519. ...v,
  520. paramType: v.typeCode,
  521. paramValue: v.paramValue ?? [],
  522. };
  523. });
  524. if (value) {
  525. //新增选中新增的
  526. chooseParameter(item);
  527. } else {
  528. // 取消选中最后一个
  529. chooseParameter(state.paramArr[state.paramArr.length - 1]);
  530. }
  531. };
  532. // 选择参数 切换当前
  533. const chooseParameter = (item: any) => {
  534. switch (item?.typeCode) {
  535. case 'AcceptType':
  536. state.selectArray = state.result.acceptType;
  537. break;
  538. case 'HotPots': // 热点
  539. state.selectArray = [];
  540. break;
  541. case 'SourceChannel':
  542. state.selectArray = state.result.sourceChannel;
  543. break;
  544. case 'IdentityType':
  545. state.selectArray = state.result.identityType;
  546. break;
  547. case 'OrderType':
  548. state.selectArray = state.result.orderType;
  549. break;
  550. case 'LicenceType': //证件类型
  551. state.selectArray = state.result.certType.map((item: any) => {
  552. return {
  553. key: item.dicDataValue,
  554. value: item.dicDataName,
  555. };
  556. });
  557. break;
  558. case 'EmergencyLevel':
  559. state.selectArray = state.result.emergencyLevel;
  560. break;
  561. case 'DefaultTime': //默认参数
  562. state.selectArray = [];
  563. break;
  564. default:
  565. break;
  566. }
  567. // state.selectArray = state.result[state.currentParam.typeCode];
  568. state.paramArr.forEach((v: any) => {
  569. v.active = item.typeCode === v.paramType;
  570. });
  571. state.currentParam = state.paramArr.find((v: any) => v.paramType === item?.typeCode);
  572. getEnableAcceptType();
  573. getSelectedParam();
  574. };
  575. // 新增
  576. const handleAdd = () => {
  577. state.currentParam.paramValue.push({
  578. id: guid(),
  579. paramType: state.currentParam.paramType,
  580. paramTypeName: '',
  581. paramTypeValue: '',
  582. timeLimitValue: 1,
  583. hour: '',
  584. });
  585. getEnableAcceptType();
  586. getSelectedParam();
  587. };
  588. // 删除
  589. const handleDelete = (row: any, index: number) => {
  590. ElMessageBox.confirm(`确定要删除?`, '提示', {
  591. confirmButtonText: '确定',
  592. cancelButtonText: '取消',
  593. type: 'warning',
  594. draggable: true,
  595. cancelButtonClass: 'default-button',
  596. })
  597. .then(() => {
  598. state.currentParam.paramValue.splice(index, 1);
  599. getEnableAcceptType();
  600. getSelectedParam();
  601. })
  602. .catch(() => {});
  603. };
  604. // 获取可用的数组
  605. const getEnableAcceptType = () => {
  606. if (state.currentParam?.paramValue.length) {
  607. const array = state.currentParam.paramValue.map((v: any) => v.paramTypeValue);
  608. state.selectArray.forEach((v: any) => {
  609. v.disabled = array.includes(v.key);
  610. });
  611. }
  612. };
  613. // 获取已经配置的列表
  614. const getSelectedParam = () => {
  615. const arr = state.paramArr.flatMap((i: any) => i.paramValue).filter((j: any) => j.paramTypeName && j.id && j.timeLimitType);
  616. state.paramSelect = arr.map((v: any) => {
  617. const { id } = v;
  618. const selected = state.paramSelect.find((j: any) => j.id === id);
  619. return {
  620. ...v,
  621. active: selected?.active ?? false,
  622. name: paramTypeNameType[v.paramType] + '-' + v.paramTypeName,
  623. };
  624. });
  625. };
  626. // 选择已配置的
  627. const selectParameter = (item: any) => {
  628. state.paramSelect.forEach((v: any) => {
  629. if (item.id === v.id) {
  630. v.active = !v.active;
  631. }
  632. });
  633. // 排序数组
  634. state.priority = state.paramSelect.filter((v: any) => {
  635. return v.active;
  636. });
  637. state.priority = state.priority.map((item: any, index: number) => {
  638. return {
  639. ...item,
  640. sort: index,
  641. code: item.id,
  642. };
  643. });
  644. };
  645. //结束拖拽事件
  646. const onEnd = () => {
  647. state.priority = state.priority.map((item: any, index: number) => {
  648. return {
  649. ...item,
  650. sort: index,
  651. code: item.id,
  652. };
  653. });
  654. };
  655. // 新增组合
  656. const combinationAdd = () => {
  657. state.combination.push({
  658. id: guid(),
  659. combinationName: '',
  660. combinationDisplayParam: '',
  661. combinationParam: [],
  662. timeLimitValue: 1,
  663. hour: '',
  664. });
  665. };
  666. // 删除组合
  667. const combinationDelete = (row: any, index: number) => {
  668. ElMessageBox.confirm(`确定要删除?`, '提示', {
  669. confirmButtonText: '确定',
  670. cancelButtonText: '取消',
  671. type: 'warning',
  672. draggable: true,
  673. cancelButtonClass: 'default-button',
  674. })
  675. .then(() => {
  676. state.combination.splice(index, 1);
  677. getEnableAcceptType();
  678. getSelectedParam();
  679. })
  680. .catch(() => {});
  681. };
  682. // 选择组合参数
  683. const chooseCombination = (row: any) => {
  684. state.paramForm = row;
  685. state.paramDialog = true;
  686. };
  687. // 选择组合热点
  688. const getComHotspot = (val: any, e: any) => {
  689. state.hotspotExternalCom = [];
  690. state.externalCom = [];
  691. state.hotspotExternalCom = getParentId(e, state.externalCom);
  692. state.paramForm.hotspotSpliceName = val.hotSpotFullName;
  693. };
  694. // 删除组合参数
  695. const clearCombinationParam = (val: any) => {
  696. let item = state.combination.find((item: any) => item.id === state.paramForm.id);
  697. item.combinationParam = item.combinationParam.filter((v: any) => v.paramType !== val);
  698. };
  699. // 参数组合确定
  700. const onConfirmCom = () => {
  701. let comName: string[] = [];
  702. let item = state.combination.find((item: any) => item.id === state.paramForm.id);
  703. if (item) {
  704. if (item.acceptType?.value) {
  705. item.combinationParam.push({
  706. paramName: item.acceptType.value,
  707. paramValue: item.acceptType.key,
  708. hotParamParent: '',
  709. paramType: 'AcceptType',
  710. });
  711. comName.push(`受理类型-${item.acceptType.value}`);
  712. }
  713. if (item?.hotspot) {
  714. item.combinationParam.push({
  715. paramName: item.hotspotSpliceName,
  716. paramValue: item.hotspot,
  717. hotParamParent: state.hotspotExternalCom.join(','),
  718. paramType: 'HotPots',
  719. });
  720. comName.push(`热点分类-${item.hotspotSpliceName}`);
  721. }
  722. if (item.identityType?.value) {
  723. item.combinationParam.push({
  724. paramName: item.identityType.value,
  725. paramValue: item.identityType.key,
  726. hotParamParent: '',
  727. paramType: 'IdentityType',
  728. });
  729. comName.push(`来电人身份-${item.identityType.value}`);
  730. }
  731. if (item.sourceChannel?.value) {
  732. item.combinationParam.push({
  733. paramName: item.sourceChannel.value,
  734. paramValue: item.sourceChannel.key,
  735. hotParamParent: '',
  736. paramType: 'SourceChannel',
  737. });
  738. comName.push(`来源渠道-${item.sourceChannel.value}`);
  739. }
  740. if (item.orderType?.value) {
  741. item.combinationParam.push({
  742. paramName: item.orderType.value,
  743. paramValue: item.orderType.key,
  744. hotParamParent: '',
  745. paramType: 'OrderType',
  746. });
  747. comName.push(`工单类型-${item.orderType.value}`);
  748. }
  749. if (item.certType?.dicDataName) {
  750. item.combinationParam.push({
  751. paramName: item.certType.dicDataName,
  752. paramValue: item.certType.dicDataValue,
  753. hotParamParent: '',
  754. paramType: 'LicenceType',
  755. });
  756. comName.push(`证件类型-${item.certType.dicDataName}`);
  757. }
  758. if (item.emergencyLevel?.value) {
  759. item.combinationParam.push({
  760. paramName: item.emergencyLevel.value,
  761. paramValue: item.emergencyLevel.key,
  762. hotParamParent: '',
  763. paramType: 'EmergencyLevel',
  764. });
  765. comName.push(`紧急程度-${item.emergencyLevel.value}`);
  766. }
  767. // if(state.paramForm.emergencyLevel.value){
  768. // state.paramForm.push({
  769. // paramName:state.paramForm.emergencyLevel.value,
  770. // paramValue:state.paramForm.emergencyLevel.key,
  771. // hotParamParent:'',
  772. // paramType:'EmergencyLevel'
  773. // })
  774. // comName+=`默认参数-${state.paramForm.emergencyLevel.value}&`;
  775. // }
  776. }
  777. state.paramForm.hotParamParent = state.hotspotExternalCom.join(',');
  778. item.combinationParam = removeDuplicate(item.combinationParam, 'paramType');
  779. if (item.combinationParam.length < 2) {
  780. ElMessageBox.alert('一个组合中至少包含两个参数', '提示', {
  781. confirmButtonText: '确定',
  782. });
  783. return;
  784. }
  785. item.combinationDisplayParam = comName.join('&');
  786. state.paramDialog = false;
  787. };
  788. // 定义一个函数来检查某个属性是否存在,如果不存在就给出提示信息,并返回false
  789. const checkProperty = (obj: any, property: string, message: string) => {
  790. if (!obj[property]) {
  791. ElMessage.warning(message);
  792. return false;
  793. }
  794. return true;
  795. };
  796. // 暂存
  797. const onSubmit = async (formEl: FormInstance | undefined) => {
  798. if (!formEl) return;
  799. await formEl.validate((valid: boolean) => {
  800. if (!valid) return;
  801. let arr: any = [];
  802. for (let i of state.paramArr) {
  803. if (i.paramValue.length) {
  804. for (let j of i.paramValue) {
  805. // 检查paramTypeName是否存在
  806. if (!checkProperty(j, 'paramTypeName', `请选择${i.name}`)) return;
  807. // 检查timeLimitValue是否存在
  808. if (!checkProperty(j, 'timeLimitValue', `请填写${i.name}的时限`)) return;
  809. // 检查timeLimitType是否存在
  810. if (!checkProperty(j, 'timeLimitType', `请选择${i.name}的单位`)) return;
  811. arr.push(j);
  812. }
  813. }
  814. }
  815. if (!arr.length) {
  816. ElMessage.warning(`请选择参数`);
  817. return;
  818. }
  819. for (let i of state.combination) {
  820. // 检查combinationName是否存在
  821. if (!checkProperty(i, 'combinationName', `请填写组合名称`)) return;
  822. // 检查combinationDisplayParam是否存在
  823. if (!checkProperty(i, 'combinationDisplayParam', `请选择组合参数`)) return;
  824. if (i.combinationParam.length.length < 2) {
  825. ElMessageBox.alert('一个组合中至少包含两个参数', '提示', {
  826. confirmButtonText: '确定',
  827. });
  828. return;
  829. }
  830. // 检查timeLimitValue是否存在
  831. if (!checkProperty(i, 'timeLimitValue', `请填写时限`)) return;
  832. // 检查timeLimit是否存在或者为0
  833. if (!checkProperty(i, 'timeLimit', `请选择组合单位`)) return;
  834. }
  835. let req = {
  836. ...state.ruleForm,
  837. paramArr: arr,
  838. priority: state.priority,
  839. combination: state.combination,
  840. };
  841. if (state.timeLimitId) {
  842. req.id = state.timeLimitId;
  843. timeLimitUpdate(req).then(() => {
  844. ElMessage.success('操作成功');
  845. emit('updateList');
  846. state.dialogVisible = false;
  847. });
  848. } else {
  849. timeLimitAdd(req).then((res: any) => {
  850. state.timeLimitId = res.result;
  851. emit('updateList');
  852. ElMessage.success('操作成功');
  853. });
  854. }
  855. });
  856. };
  857. // 确定
  858. const onConfirm = async (formEl: FormInstance | undefined) => {
  859. if (!formEl) return;
  860. await formEl.validate((valid: boolean) => {
  861. if (!valid) return;
  862. let arr: any = [];
  863. for (let i of state.paramArr) {
  864. if (i.paramValue.length) {
  865. for (let j of i.paramValue) {
  866. // 检查paramTypeName是否存在
  867. if (!checkProperty(j, 'paramTypeName', `请选择${i.name}`)) return;
  868. // 检查timeLimitValue是否存在
  869. if (!checkProperty(j, 'timeLimitValue', `请填写${i.name}的时限`)) return;
  870. // 检查timeLimitType是否存在
  871. if (!checkProperty(j, 'timeLimitType', `请选择${i.name}的单位`)) return;
  872. arr.push(j);
  873. }
  874. }
  875. }
  876. if (!arr.length) {
  877. ElMessage.warning(`请选择参数`);
  878. return;
  879. }
  880. for (let i of state.combination) {
  881. // 检查combinationName是否存在
  882. if (!checkProperty(i, 'combinationName', `请填写组合名称`)) return;
  883. // 检查combinationDisplayParam是否存在
  884. if (!checkProperty(i, 'combinationDisplayParam', `请选择组合参数`)) return;
  885. if (i.combinationParam.length.length < 2) {
  886. ElMessageBox.alert('一个组合中至少包含两个参数', '提示', {
  887. confirmButtonText: '确定',
  888. });
  889. return;
  890. }
  891. // 检查timeLimitValue是否存在
  892. if (!checkProperty(i, 'timeLimitValue', `请填写时限`)) return;
  893. // 检查timeLimit是否存在或者为0
  894. if (!checkProperty(i, 'timeLimit', `请选择组合单位`)) return;
  895. }
  896. let req = {
  897. ...state.ruleForm,
  898. paramArr: arr,
  899. priority: state.priority,
  900. combination: state.combination,
  901. };
  902. if (state.timeLimitId) {
  903. // 更新
  904. req.id = state.timeLimitId;
  905. timeLimitUpdate(req).then(() => {
  906. ElMessage.success('操作成功');
  907. emit('updateList');
  908. state.dialogVisible = false;
  909. });
  910. } else {
  911. // 新增
  912. timeLimitAdd(req).then((res: any) => {
  913. state.timeLimitId = res.result;
  914. ElMessage.success('操作成功');
  915. emit('updateList');
  916. state.dialogVisible = false;
  917. });
  918. }
  919. });
  920. };
  921. //暴漏变量和方法
  922. defineExpose({ closeDialog, openDialog });
  923. </script>
  924. <style lang="scss" scoped>
  925. .system-timeLimit-add-container {
  926. .collapse-box {
  927. :deep(.el-collapse-item__header) {
  928. background-color: var(--hotline-bg-main-color);
  929. height: 40px;
  930. border-radius: var(--el-border-radius-base);
  931. }
  932. :deep(.el-collapse-item__content) {
  933. padding-bottom: 0 !important;
  934. .el-form-item {
  935. margin-bottom: 5px;
  936. .el-form-item__content {
  937. line-height: 24px;
  938. }
  939. }
  940. }
  941. .collapse-container {
  942. padding: 10px;
  943. .plug-container {
  944. border: var(--el-border);
  945. border-radius: var(--el-border-radius-base);
  946. margin-bottom: 15px;
  947. &:last-child {
  948. margin-bottom: 0;
  949. }
  950. .plug-container-title {
  951. padding: 10px 15px;
  952. font-weight: bold;
  953. border-bottom: var(--el-border);
  954. font-size: var(--el-font-size-medium);
  955. }
  956. }
  957. }
  958. }
  959. :deep(.el-collapse-item__wrap) {
  960. border-bottom: 0;
  961. }
  962. :deep(.el-collapse) {
  963. border-bottom: 0;
  964. }
  965. :deep(.el-tabs__nav-wrap::after) {
  966. height: 100% !important;
  967. }
  968. .parameter-choose {
  969. &-one {
  970. cursor: pointer;
  971. text-align: center;
  972. height: 34px;
  973. line-height: 34px;
  974. color: var(--el-color-primary);
  975. width: calc(100% - 10px);
  976. padding: 0 5px;
  977. border: 1px solid transparent;
  978. }
  979. .active {
  980. border: 1px solid var(--el-color-primary);
  981. border-radius: var(--el-border-radius-base);
  982. }
  983. }
  984. .parameter-stop {
  985. &-one {
  986. cursor: pointer;
  987. text-align: center;
  988. height: 34px;
  989. line-height: 34px;
  990. width: calc(100% - 10px);
  991. padding: 0 5px;
  992. }
  993. .active {
  994. border: 1px solid var(--el-color-primary);
  995. border-radius: var(--el-border-radius-base);
  996. color: var(--el-color-primary);
  997. }
  998. }
  999. .parameter-sort {
  1000. display: flex;
  1001. flex-wrap: wrap;
  1002. &-one {
  1003. cursor: pointer;
  1004. text-align: center;
  1005. height: 34px;
  1006. line-height: 34px;
  1007. }
  1008. }
  1009. .omit {
  1010. display: inline-block;
  1011. }
  1012. }
  1013. </style>