index.vue 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--部门数据-->
  5. <el-col :span="4" :xs="24">
  6. <div class="head-container">
  7. <el-input v-model="deptName" placeholder="请输入部门名称" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px" />
  8. </div>
  9. <div class="head-container">
  10. <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree" @node-click="handleNodeClick" />
  11. </div>
  12. </el-col>
  13. <!--用户数据-->
  14. <el-col :span="20" :xs="24">
  15. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  16. <el-form-item label="员工后台昵称" prop="nickName">
  17. <el-input v-model="queryParams.nickName" placeholder="请输入员工后台昵称" clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery" />
  18. </el-form-item>
  19. <el-form-item label="手机号码" prop="phonenumber">
  20. <el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery" />
  21. </el-form-item>
  22. <el-form-item label="状态" prop="status">
  23. <el-select v-model="queryParams.status" placeholder="员工状态" clearable size="small" style="width: 240px" @change="handleQuery">
  24. <el-option v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="企微状态" prop="qwStatus">
  28. <el-select v-model="queryParams.qwStatus" placeholder="企微绑定状态" clearable size="small" style="width: 240px" @change="handleQuery">
  29. <el-option v-for="dict in qwStatusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="创建时间">
  33. <el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  37. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  38. </el-form-item>
  39. </el-form>
  40. <el-row :gutter="10" class="mb8">
  41. <el-col :span="1.5">
  42. <el-button plain type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['company:user:add']">新增</el-button>
  43. </el-col>
  44. <el-col :span="1.5">
  45. <el-button plain type="success" icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['company:user:edit']">修改</el-button>
  46. </el-col>
  47. <el-col :span="1.5">
  48. <el-button plain type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['company:user:remove']">删除</el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button plain type="info" icon="el-icon-upload2" size="mini" @click="handleImport" v-hasPermi="['company:user:import']">导入</el-button>
  52. </el-col>
  53. <el-col :span="1.5">
  54. <el-button plain type="warning" icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['company:user:export']">导出</el-button>
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-button
  58. type="primary"
  59. plain
  60. size="mini"
  61. @click="synOpen=true"
  62. v-hasPermi="['qw:user:sync']"
  63. >同步企微员工和部门</el-button>
  64. </el-col>
  65. <el-col :span="1.5">
  66. <el-button
  67. type="primary"
  68. plain
  69. size="mini"
  70. @click="synNameOpen=true"
  71. v-hasPermi="['qw:user:sync']"
  72. >同步企微员工名称</el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button
  76. type="primary"
  77. plain
  78. size="mini"
  79. :disabled="multiple"
  80. @click="handerCompanyUserAreaList"
  81. >批量设置销售所属区域</el-button>
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-button
  85. type="primary"
  86. plain
  87. size="mini"
  88. :disabled="multiple"
  89. @click="handleSetRegister"
  90. >设置单独注册会员</el-button>
  91. </el-col>
  92. <el-col :span="1.5">
  93. <el-button
  94. type="primary"
  95. plain
  96. size="mini"
  97. :disabled="multiple"
  98. @click="handleAllowedAllRegister"
  99. >允许注册会员开关</el-button>
  100. </el-col>
  101. <el-col :span="1.5">
  102. <el-button
  103. type="primary"
  104. plain
  105. size="mini"
  106. @click="handleBindCompanyUserCode"
  107. >生成注册/绑定销售二维码</el-button>
  108. </el-col>
  109. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  110. </el-row>
  111. <el-table height="500" border v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
  112. <el-table-column type="selection" width="50" align="center" />
  113. <el-table-column label="ID" align="center" prop="userId" :show-overflow-tooltip="true" />
  114. <el-table-column label="员工后台账号" align="center" prop="userName" :show-overflow-tooltip="true" width="100" />
  115. <el-table-column label="员工后台昵称" align="center" prop="nickName" :show-overflow-tooltip="true" 员工后台 width="100"/>
  116. <el-table-column label="部门" align="center" prop="deptName" :show-overflow-tooltip="true" />
  117. <el-table-column label="手机号码" align="center" prop="phonenumber" width="120" />
  118. <el-table-column label="账户角色" align="center" :show-overflow-tooltip="true" width="150">
  119. <template slot-scope="scope">
  120. <span v-if="scope.row.roleNames && scope.row.roleNames.length > 0">
  121. {{ scope.row.roleNames.join('、') }}
  122. </span>
  123. <span v-else>-</span>
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="二维码" align="center" prop="qrCodeWeixin">
  127. <template slot-scope="scope">
  128. <!-- 显示已上传的二维码 -->
  129. <el-image
  130. v-if="scope.row.qrCodeWeixin"
  131. style="width: 80px; height: 80px; margin-bottom: 5px; display: block; margin-left: auto; margin-right: auto;"
  132. :src="scope.row.qrCodeWeixin"
  133. :preview-src-list="[scope.row.qrCodeWeixin]"
  134. fit="contain">
  135. <div slot="error" class="image-slot">
  136. <i class="el-icon-picture-outline"></i>
  137. </div>
  138. </el-image>
  139. <!-- 上传组件 -->
  140. <el-upload
  141. class="avatar-uploader"
  142. action="#"
  143. :show-file-list="false"
  144. :http-request="(options) => handleCustomUpload(options, scope.row)"
  145. :before-upload="(file) => beforeImageUpload(file, scope.row)"
  146. >
  147. <el-button size="small" type="primary" :loading="scope.row.uploading">
  148. {{ scope.row.qrCodeWeixin ? '更换图片' : '上传图片' }}
  149. <i class="el-icon-upload el-icon--right"></i>
  150. </el-button>
  151. </el-upload>
  152. <div v-if="scope.row.uploadError" class="el-upload__tip" style="color: red;">
  153. {{ scope.row.uploadError }}
  154. </div>
  155. </template>
  156. </el-table-column>
  157. <el-table-column label="状态" align="center">
  158. <template slot-scope="scope">
  159. <el-switch v-model="scope.row.status" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
  160. </template>
  161. </el-table-column>
  162. <el-table-column label="企微状态" align="center">
  163. <template slot-scope="scope">
  164. <dict-tag :options="qwStatusOptions" :value="scope.row.qwStatus"/>
  165. </template>
  166. </el-table-column>
  167. <el-table-column label="区域" align="center" prop="addressId">
  168. </el-table-column>
  169. <el-table-column label="创建时间" sortable align="center" prop="createTime" width="160">
  170. <template slot-scope="scope">
  171. <span>{{ parseTime(scope.row.createTime) }}</span>
  172. </template>
  173. </el-table-column>
  174. <el-table-column label="是否单独注册会员" align="center" prop="isNeedRegisterMember" width="80px">
  175. <template slot-scope="scope">
  176. <el-tag
  177. :type="scope.row.isNeedRegisterMember === 1 ? 'success' : 'info'">{{scope.row.isNeedRegisterMember === 1 ? '是' : '否' }}</el-tag>
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="创建时间" sortable align="center" prop="createTime" width="160">
  181. <template slot-scope="scope">
  182. <span>{{ parseTime(scope.row.createTime) }}</span>
  183. </template>
  184. </el-table-column>
  185. <el-table-column label="允许注册会员" align="center" prop="isNeedRegisterMember" width="80px">
  186. <template slot-scope="scope">
  187. <el-tag
  188. :type="scope.row.isAllowedAllRegister === 1 ? 'success' : 'info'">{{scope.row.isAllowedAllRegister === 1 ? '是' : '否' }}</el-tag>
  189. </template>
  190. </el-table-column>
  191. <el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
  192. <template slot-scope="scope">
  193. <el-button
  194. size="mini"
  195. type="text"
  196. icon="el-icon-connection"
  197. plain
  198. v-if="scope.row.doctorId!=null"
  199. @click="handleUpdateDoctor(scope.row)"
  200. >换绑医生</el-button>
  201. <el-button
  202. size="mini"
  203. type="text"
  204. plain
  205. icon="el-icon-link"
  206. v-else
  207. @click="handleUpdateDoctor(scope.row)"
  208. >绑定医生</el-button>
  209. <el-button
  210. size="mini"
  211. type="text"
  212. icon="el-icon-unlock"
  213. plain
  214. v-if="scope.row.doctorId!=null"
  215. @click="handleUnBindUserId(scope.row)"
  216. >解绑医生</el-button>
  217. <el-button
  218. v-if="scope.row.qwStatus == 0"
  219. size="mini"
  220. type="text"
  221. icon="el-icon-edit"
  222. @click="qwBind(scope.row)"
  223. v-hasPermi="['qw:user:bind']"
  224. >绑定企微</el-button>
  225. <el-button
  226. v-else
  227. size="mini"
  228. type="text"
  229. icon="el-icon-edit"
  230. @click="qwBind(scope.row)"
  231. v-hasPermi="['qw:user:bind']"
  232. >查或换绑企微</el-button>
  233. <el-button v-if="scope.row.userType !== '00'" size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['company:user:edit']">修改</el-button>
  234. <el-button v-if="scope.row.userType !== '00'" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['company:user:remove']">删除</el-button>
  235. <el-button size="mini" type="text" icon="el-icon-key" @click="handleResetPwd(scope.row)" v-hasPermi="['company:user:resetPwd']">重置密码</el-button>
  236. </template>
  237. </el-table-column>
  238. </el-table>
  239. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  240. </el-col>
  241. </el-row>
  242. <el-dialog title="绑定企微账号" :visible.sync="qwOpen" width="800px" append-to-body >
  243. <el-form ref="form" :model="form" label-width="80px" >
  244. <el-form-item label="查询" prop="companyUserId">
  245. <el-button type="primary" icon="el-icon-search" @click="selectQwUser()" size="mini">搜索账号</el-button>
  246. </el-form-item>
  247. <el-form-item label="企微账号" prop="companyUserId">
  248. <el-tag
  249. style="margin-left: 5px"
  250. size="medium"
  251. :key="id"
  252. v-for="id in qwUser"
  253. closable
  254. :disable-transitions="false"
  255. @close="handleClosegroupUser(id)">
  256. <span v-for="list in qwUserList" :key="list.qwUserId" v-if="list.id==id">{{list.qwUserName}}({{list.corpName}})
  257. </span>
  258. </el-tag>
  259. </el-form-item>
  260. </el-form>
  261. <div slot="footer" class="dialog-footer">
  262. <el-button type="primary" @click="qwSubmitForm">绑 定</el-button>
  263. <el-button @click="qwCancel">取 消</el-button>
  264. </div>
  265. </el-dialog>
  266. <el-dialog title="选择企微主体" :visible.sync="synOpen" width="800px" append-to-body>
  267. <el-form label-width="80px">
  268. <el-form-item label="企微公司" prop="corpId">
  269. <el-select v-model="synform.corpId" placeholder="企微公司" >
  270. <el-option
  271. v-for="dict in myQwCompanyList"
  272. :key="dict.dictValue"
  273. :label="dict.dictLabel"
  274. :value="dict.dictValue"
  275. />
  276. </el-select>
  277. </el-form-item>
  278. </el-form>
  279. <div slot="footer" class="dialog-footer">
  280. <el-button type="primary" @click="synSubmitForm">确 定</el-button>
  281. <el-button @click="synOpen=false">取 消</el-button>
  282. </div>
  283. </el-dialog>
  284. <el-dialog title="选择企微主体" :visible.sync="synNameOpen" width="800px" append-to-body>
  285. <el-form label-width="80px">
  286. <el-form-item label="企微公司" prop="corpId">
  287. <el-select v-model="synNameform.corpId" placeholder="企微公司" >
  288. <el-option
  289. v-for="dict in myQwCompanyList"
  290. :key="dict.dictValue"
  291. :label="dict.dictLabel"
  292. :value="dict.dictValue"
  293. />
  294. </el-select>
  295. </el-form-item>
  296. </el-form>
  297. <div slot="footer" class="dialog-footer">
  298. <el-button type="primary" @click="synNameSubmitForm">确 定</el-button>
  299. <el-button @click="synNameOpen=false">取 消</el-button>
  300. </div>
  301. </el-dialog>
  302. <!-- 添加或修改参数配置对话框 -->
  303. <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
  304. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  305. <el-row>
  306. <el-col :span="12">
  307. <!-- <el-form-item label="员工账号" prop="userName">-->
  308. <!-- <el-input v-model="form.userName" placeholder="请输入员工后台账号" />-->
  309. <!-- </el-form-item>-->
  310. <el-form-item label="员工姓名" prop="nickName">
  311. <el-input v-model="form.nickName" placeholder="请输入员工后台昵称" />
  312. </el-form-item>
  313. </el-col>
  314. <el-col :span="12">
  315. <el-form-item label="归属部门" prop="deptId">
  316. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
  317. </el-form-item>
  318. </el-col>
  319. </el-row>
  320. <el-row>
  321. <el-col :span="12">
  322. <el-form-item label="手机号码" prop="phonenumber">
  323. <el-input v-model="form.phonenumber" placeholder="请输入手机号码" maxlength="11" />
  324. </el-form-item>
  325. </el-col>
  326. <el-col :span="12">
  327. <el-form-item label="邮箱" prop="email">
  328. <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
  329. </el-form-item>
  330. </el-col>
  331. </el-row>
  332. <el-row>
  333. <el-col :span="12">
  334. <el-form-item label="员工账号" prop="userName">
  335. <el-input v-model="form.userName" placeholder="请输入员工工号" />
  336. </el-form-item>
  337. </el-col>
  338. <el-col :span="12">
  339. <el-form-item v-if="form.userId == undefined" label="用户密码" prop="password">
  340. <el-input v-model="form.password" placeholder="请输入用户密码" type="password" show-password />
  341. </el-form-item>
  342. </el-col>
  343. </el-row>
  344. <el-row>
  345. <el-col :span="12">
  346. <el-form-item label="员工性别">
  347. <el-select v-model="form.sex" placeholder="请选择">
  348. <el-option v-for="dict in sexOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"></el-option>
  349. </el-select>
  350. </el-form-item>
  351. </el-col>
  352. <el-col :span="12">
  353. <el-form-item label="状态">
  354. <el-radio-group v-model="form.status">
  355. <el-radio v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
  356. </el-radio-group>
  357. </el-form-item>
  358. </el-col>
  359. </el-row>
  360. <el-row>
  361. <el-col :span="12">
  362. <el-form-item label="岗位">
  363. <el-select v-model="form.postIds" multiple placeholder="请选择">
  364. <el-option v-for="item in postOptions" :key="item.postId" :label="item.postName" :value="item.postId" :disabled="item.status == 1"></el-option>
  365. </el-select>
  366. </el-form-item>
  367. </el-col>
  368. <el-col :span="12">
  369. <el-form-item label="角色">
  370. <el-select v-model="form.roleIds" multiple placeholder="请选择">
  371. <el-option v-for="item in roleOptions" :key="item.roleId" :label="item.roleName" :value="item.roleId" :disabled="item.status == 1"></el-option>
  372. </el-select>
  373. </el-form-item>
  374. </el-col>
  375. </el-row>
  376. <el-row>
  377. <el-col :span="12">
  378. <el-form-item label="身份证号">
  379. <el-input v-model="form.idCard" placeholder="请输入身份证号" maxlength="18" />
  380. </el-form-item>
  381. </el-col>
  382. <el-col :span="12">
  383. <el-form-item label="销售区域" prop="addressId">
  384. <el-select v-model="form.addressId" filterable placeholder="请选择所属销售的区域" style="width: 200px;">
  385. <el-option
  386. v-for="item in citysAreaList"
  387. :key="item.cityId"
  388. :label="item.cityName"
  389. :value="item.cityId"
  390. ></el-option>
  391. </el-select>
  392. </el-form-item>
  393. </el-col>
  394. </el-row>
  395. <!-- <el-row>-->
  396. <!-- <el-col :span="24">-->
  397. <!-- <el-form-item label="数据权限">-->
  398. <!-- <el-radio-group v-model="form.userType">-->
  399. <!-- <el-radio v-for="dict in userTypeOptions" :key="dict.dictValue" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>-->
  400. <!-- </el-radio-group>-->
  401. <!-- </el-form-item>-->
  402. <!-- </el-col>-->
  403. <!-- </el-row>-->
  404. <!-- <el-row>
  405. <el-col :span="24">
  406. <el-form-item label="看课域名">
  407. <el-input
  408. v-model="form.domain"
  409. style="width: 250px"
  410. placeholder="请生成域名"
  411. @change="onDomainBlur"
  412. disabled
  413. ></el-input>
  414. <el-button type="primary" style="margin-left: 20px" @click="generateDomain">生成域名</el-button>
  415. </el-form-item>
  416. </el-col>
  417. </el-row>-->
  418. <el-row>
  419. <el-col :span="24">
  420. <el-form-item label="备注">
  421. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
  422. </el-form-item>
  423. </el-col>
  424. </el-row>
  425. </el-form>
  426. <div slot="footer" class="dialog-footer">
  427. <el-button type="primary" @click="submitForm">确 定</el-button>
  428. <el-button @click="cancel">取 消</el-button>
  429. </div>
  430. </el-dialog>
  431. <el-dialog :title="title" :visible.sync="bindCompanyOpen" width="700px" append-to-body>
  432. <el-form ref="formBindCompany" :model="formBindCompany" :rules="bindCompanyRules" label-width="80px">
  433. <el-row>
  434. <el-col :span="12">
  435. <el-form-item label="企微主体" prop="corpId">
  436. <el-select v-model="formBindCompany.corpId" placeholder="企微主体" size="small">
  437. <el-option
  438. v-for="dict in myQwCompanyList"
  439. :key="dict.dictValue"
  440. :label="dict.dictLabel"
  441. :value="dict.dictValue"
  442. />
  443. </el-select>
  444. </el-form-item>
  445. </el-col>
  446. </el-row>
  447. <el-row>
  448. <el-col :span="12">
  449. <el-form-item label="归属部门" prop="deptId">
  450. <treeselect v-model="formBindCompany.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
  451. </el-form-item>
  452. </el-col>
  453. </el-row>
  454. <el-row>
  455. <el-col :span="12">
  456. <el-form-item label="角色" prop="roleIds">
  457. <el-select v-model="formBindCompany.roleIds" multiple placeholder="请选择">
  458. <el-option v-for="item in roleOptions" :key="item.roleId" :label="item.roleName" :value="item.roleId "></el-option>
  459. </el-select>
  460. </el-form-item>
  461. </el-col>
  462. </el-row>
  463. <el-row>
  464. <el-col :span="12">
  465. <el-form-item label="销售区域" prop="addressId">
  466. <el-select v-model="formBindCompany.addressId" filterable placeholder="请选择所属销售的区域" style="width: 200px;">
  467. <el-option
  468. v-for="item in citysAreaList"
  469. :key="item.cityId"
  470. :label="item.cityName"
  471. :value="item.cityId"
  472. ></el-option>
  473. </el-select>
  474. </el-form-item>
  475. </el-col>
  476. </el-row>
  477. </el-form>
  478. <div slot="footer" class="dialog-footer">
  479. <el-button type="primary" @click="submitBingCompanyForm">确 定</el-button>
  480. <el-button @click="cancelBind">取 消</el-button>
  481. </div>
  482. </el-dialog>
  483. <el-dialog :title="user.title" :visible.sync="user.open" width="1000px" append-to-body>
  484. <selectUser ref="selectUser" @bindQwUser="bindQwUser"></selectUser>
  485. </el-dialog>
  486. <el-dialog :title="companyUserArea.title" :visible.sync="companyUserArea.open" width="300px" append-to-body>
  487. <el-select v-model="addressId" filterable placeholder="请选择所属销售的区域" style="width: 200px;">
  488. <el-option
  489. v-for="item in citysAreaList"
  490. :key="item.cityId"
  491. :label="item.cityName"
  492. :value="item.cityId"
  493. ></el-option>
  494. </el-select>
  495. <div slot="footer" style="text-align: center;">
  496. <el-button type="primary" @click="submitFormArea(addressId)">确 定</el-button>
  497. <el-button @click="cancelArea">取 消</el-button>
  498. </div>
  499. </el-dialog>
  500. <!-- 设置单独注册会员弹窗 -->
  501. <el-dialog title="设置单独注册会员" :visible.sync="registerOpen" width="400px" append-to-body>
  502. <el-form ref="registerForm" :model="registerForm" label-width="180px">
  503. <el-form-item label="是否需要开启单独注册">
  504. <el-switch v-model="registerForm.status" active-value="true" inactive-value="false"></el-switch>
  505. </el-form-item>
  506. </el-form>
  507. <div slot="footer" class="dialog-footer">
  508. <el-button type="primary" @click="submitRegisterForm">确 定</el-button>
  509. <el-button @click="registerOpen = false">取 消</el-button>
  510. </div>
  511. </el-dialog>
  512. <!-- 是否允许所有方式注册会员弹窗 -->
  513. <el-dialog title="允许注册会员" :visible.sync="allowedAllRegisterOpen" width="400px" append-to-body>
  514. <el-form ref="registerForm" :model="allowedAllRegisterForm" label-width="180px">
  515. <el-form-item label="是否允许注册会员">
  516. <el-switch v-model="allowedAllRegisterForm.status" active-value="true" inactive-value="false"></el-switch>
  517. </el-form-item>
  518. </el-form>
  519. <div slot="footer" class="dialog-footer">
  520. <el-button type="primary" @click="submitAllowedAllRegisterForm">确 定</el-button>
  521. <el-button @click="allowedAllRegisterOpen = false">取 消</el-button>
  522. </div>
  523. </el-dialog>
  524. <el-dialog :title="bindCompanyUrl.title" v-if="bindCompanyUrl.open" :visible.sync="bindCompanyUrl.open" width="450px" append-to-body>
  525. <div style="padding-bottom:15px;" >
  526. <img :src="bindCompanyUrl.url" width="400px">
  527. </div>
  528. <div slot="footer" class="dialog-footer">
  529. <el-button @click="downloadImage(bindCompanyUrl.url, bindCompanyUrl.name+'.png')">下载二维码</el-button>
  530. </div>
  531. </el-dialog>
  532. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  533. <el-upload
  534. ref="upload"
  535. :limit="1"
  536. accept=".xlsx, .xls"
  537. :headers="upload.headers"
  538. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  539. :disabled="upload.isUploading"
  540. :on-progress="handleFileUploadProgress"
  541. :on-success="handleFileSuccess"
  542. :auto-upload="false"
  543. drag
  544. >
  545. <i class="el-icon-upload"></i>
  546. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  547. <div class="el-upload__tip text-center" slot="tip">
  548. <div class="el-upload__tip" slot="tip">
  549. </div>
  550. <span>仅允许导入xls、xlsx格式文件。</span>
  551. <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
  552. </div>
  553. </el-upload>
  554. <div slot="footer" class="dialog-footer">
  555. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  556. <el-button @click="upload.open = false">取 消</el-button>
  557. </div>
  558. </el-dialog>
  559. <el-dialog :title="doctor.title" :visible.sync="doctor.open" width="800px" append-to-body>
  560. <selectDoctor ref="selectDoctor" @bindCompanyUserDoctorId="bindCompanyUserDoctorId"></selectDoctor>
  561. </el-dialog>
  562. </div>
  563. </template>
  564. <script>
  565. import {
  566. qwList,
  567. delUser,
  568. addUser,
  569. getUser,
  570. updateUser,
  571. exportUser,
  572. resetUserPwd,
  573. importTemplate,
  574. getCitysAreaList,
  575. changeUserStatus,
  576. generateSubDomain,
  577. setIsRegisterMember,
  578. updateCompanyUserAreaList,
  579. isAllowedAllRegister, unBindDoctorId, bindDoctorId
  580. } from "@/api/company/companyUser";
  581. import { getToken } from "@/utils/auth";
  582. import { treeselect } from "@/api/company/companyDept";
  583. import Treeselect from "@riophae/vue-treeselect";
  584. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  585. import {bindQwUser, getQwUserList, addQwUser, getQwUser, getQwUserByIds,addQwUserName} from '@/api/qw/user';
  586. import { syncDept } from '@/api/qw/qwDept';
  587. import { getMyQwUserList,getMyQwCompanyList } from "@/api/qw/user";
  588. import selectUser from "@/views/company/components/selectQwUser.vue";
  589. import { getConfigByKey } from "@/api/company/companyConfig";
  590. import axios from "axios";
  591. import {addCodeUrl} from "../../../api/company/companyUser";
  592. import selectDoctor from "@/views/qw/user/selectDoctor.vue";
  593. export default {
  594. name: "User",
  595. components: {selectDoctor, Treeselect ,selectUser},
  596. data() {
  597. return {
  598. doctor: {
  599. open: false,
  600. title: '绑定医生'
  601. },
  602. doctorForm: {
  603. userId: null,
  604. doctorId: null
  605. },
  606. uploadUrl: process.env.VUE_APP_BASE_API+"/company/user/common/uploadOSS",
  607. // 遮罩层
  608. loading: false,
  609. qwUserList:[],
  610. qwUserId:[],
  611. myQwCompanyList:[],
  612. qwUser:[],
  613. user:{
  614. open:false,
  615. title:"搜索企业"
  616. },
  617. // 选中数组
  618. ids: [],
  619. synform:{corpId:null},
  620. synOpen:false,
  621. synNameform:{corpId:null},
  622. synNameOpen:false,
  623. // 非单个禁用
  624. single: true,
  625. // 非多个禁用
  626. multiple: true,
  627. // 显示搜索条件
  628. showSearch: true,
  629. // 总条数
  630. total: 0,
  631. // 用户表格数据
  632. userList: null,
  633. // 弹出层标题
  634. title: "",
  635. // 部门树选项
  636. deptOptions: undefined,
  637. // 是否显示弹出层
  638. open: false,
  639. bindCompanyOpen: false,
  640. qwOpen:false,
  641. // 部门名称
  642. deptName: undefined,
  643. // 日期范围
  644. dateRange: [],
  645. // 状态数据字典
  646. statusOptions: [],
  647. // 性别状态字典
  648. sexOptions: [],
  649. // 岗位选项
  650. postOptions: [],
  651. // 角色选项
  652. roleOptions: [],
  653. userTypeOptions:[
  654. { "dictLabel": "临时管理员","dictValue": "02"},
  655. { "dictLabel": "普通用户","dictValue": "01"}
  656. ],
  657. qwForm:{
  658. id:null,
  659. companyUserId:null,
  660. },
  661. companyUserArea:{
  662. open:false,
  663. title:"分配区域",
  664. },
  665. //选择的区域
  666. addressId:null,
  667. citysAreaList:[],
  668. // 表单参数
  669. form: {},
  670. formBindCompany: {},
  671. bindCompanyUrl:{
  672. open:false,
  673. title:"绑定/注册销售二维码",
  674. name:null,
  675. url:null,
  676. },
  677. form1: {},
  678. defaultProps: {
  679. children: "children",
  680. label: "label",
  681. },
  682. // 用户导入参数
  683. upload: {
  684. // 是否显示弹出层(用户导入)
  685. open: false,
  686. // 弹出层标题(用户导入)
  687. title: "",
  688. // 是否禁用上传
  689. isUploading: false,
  690. // 是否更新已经存在的用户数据
  691. updateSupport: 0,
  692. // 设置上传的请求头部
  693. headers: { Authorization: "Bearer " + getToken() },
  694. // 上传的地址
  695. url: process.env.VUE_APP_BASE_API + "/company/user/importCompanyUser",
  696. },
  697. // 查询参数
  698. queryParams: {
  699. pageNum: 1,
  700. pageSize: 10,
  701. userName: null,
  702. phonenumber: null,
  703. status: null,
  704. deptId: null,
  705. qwStatus:null,
  706. },
  707. qwStatusOptions:[],
  708. registerOpen: false,
  709. registerForm: {
  710. status: false
  711. },
  712. // 表单校验
  713. rules: {
  714. userName: [
  715. { required: true, message: "员工工号不能为空", trigger: "blur" },
  716. ],
  717. nickName: [
  718. { required: true, message: "员工姓名不能为空", trigger: "blur" },
  719. ],
  720. deptId: [
  721. { required: true, message: "归属部门不能为空", trigger: "blur" },
  722. ],
  723. addressId: [
  724. { required: true, message: "销售所属区域不能为空", trigger: "blur" },
  725. ],
  726. password: [
  727. { required: true, message: "员工密码不能为空", trigger: "blur" },
  728. {
  729. pattern: /^(?=.*[A-Za-z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,20}$/,
  730. message: "密码长度为 8-20 位,必须包含字母、数字和特殊字符",
  731. trigger: ["blur", "change"],
  732. }
  733. ],
  734. idCard: [
  735. { required: true, message: "身份证号不能为空", trigger: "blur" },
  736. ],
  737. // email: [
  738. // { required: true, message: "邮箱地址不能为空", trigger: "blur" },
  739. // {
  740. // type: "email",
  741. // message: "'请输入正确的邮箱地址",
  742. // trigger: ["blur", "change"],
  743. // },
  744. // ],
  745. phonenumber: [
  746. { required: true, message: "手机号码不能为空", trigger: "blur" },
  747. {
  748. pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
  749. message: "请输入正确的手机号码",
  750. trigger: "blur",
  751. },
  752. ],
  753. },
  754. // 表单校验
  755. bindCompanyRules: {
  756. deptId: [
  757. { required: true, message: "归属部门不能为空", trigger: "blur" },
  758. ],
  759. addressId: [
  760. { required: true, message: "销售所属区域不能为空", trigger: "blur" },
  761. ],
  762. roleIds: [
  763. { required: true, message: "角色不能为空", trigger: "blur" },
  764. ],
  765. corpId: [
  766. { required: true, message: "角色不能为空", trigger: "blur" },
  767. ],
  768. },
  769. // 是否允许注册会员开关
  770. allowedAllRegisterOpen: false,
  771. allowedAllRegisterForm: {
  772. status: true
  773. },
  774. };
  775. },
  776. watch: {
  777. // 根据名称筛选部门树
  778. deptName(val) {
  779. this.$refs.tree.filter(val);
  780. },
  781. },
  782. created() {
  783. this.getList();
  784. this.getTreeselect();
  785. this.getDicts("sys_normal_disable").then((response) => {
  786. this.statusOptions = response.data;
  787. });
  788. this.getDicts("company_user_sex").then((response) => {
  789. this.sexOptions = response.data;
  790. });
  791. this.getDicts("sys_qw_user_status").then(response => {
  792. this.qwStatusOptions = response.data;
  793. });
  794. getConfigByKey("his.login").then(response => {
  795. this.form1 =JSON.parse(response.data.configValue);
  796. });
  797. getCitysAreaList().then(res=>{
  798. this.citysAreaList=res.data;
  799. })
  800. getMyQwCompanyList().then(response => {
  801. this.myQwCompanyList = response.data;
  802. });
  803. },
  804. methods: {
  805. onDomainBlur() {
  806. if (this.form.domain!=null){
  807. let value = this.form.domain.trim();
  808. // 强制只保留第一个 http://
  809. const httpCount = (value.match(/http:\/\//g) || []).length;
  810. if (httpCount > 1) {
  811. value = value.replace(/(http:\/\/)+/, 'http://'); // 只留第一个
  812. }
  813. // 如果不是 http:// 开头,自动补充
  814. if (!value.startsWith('http://')) {
  815. value = 'http://' + value.replace(/^https?:\/\//, ''); // 去掉其他 http(s):// 再补
  816. }
  817. this.form.domain = value; // 重新赋值,保证输入正确
  818. // 正则校验最终格式,提醒用户
  819. const domainPattern = /^http:\/\/([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
  820. if (!domainPattern.test(this.form.domain)) {
  821. return this.$message.error('请输入正确格式的域名,如:http://xxx.xxx.com');
  822. }
  823. }
  824. },
  825. /** 查询用户列表 */
  826. getList() {
  827. this.loading = true;
  828. qwList(this.addDateRange(this.queryParams, this.dateRange)).then(
  829. (response) => {
  830. this.userList = response.rows;
  831. this.total = response.total;
  832. this.loading = false;
  833. console.log(" this.userList ", this.userList )
  834. }
  835. );
  836. },
  837. selectQwUser(){
  838. this.user.open=true;
  839. },
  840. handleClosegroupUser(list){
  841. const index = this.qwUser.findIndex(t => t === list);
  842. if (index !== -1) {
  843. this.qwUser.splice(index, 1);
  844. }
  845. },
  846. /** 查询部门下拉树结构 */
  847. getTreeselect() {
  848. treeselect().then((response) => {
  849. this.deptOptions = response.data;
  850. });
  851. },
  852. // 筛选节点
  853. filterNode(value, data) {
  854. if (!value) return true;
  855. return data.label.indexOf(value) !== -1;
  856. },
  857. // 节点单击事件
  858. handleNodeClick(data) {
  859. this.queryParams.deptId = data.id;
  860. this.getList();
  861. },
  862. // 用户状态修改
  863. handleStatusChange(row) {
  864. let text = row.status === "0" ? "启用" : "停用";
  865. this.$confirm(
  866. '确认要"' + text + '""' + row.userName + '"用户吗?',
  867. "警告",
  868. {
  869. confirmButtonText: "确定",
  870. cancelButtonText: "取消",
  871. type: "warning",
  872. }
  873. )
  874. .then(function () {
  875. return changeUserStatus(row.userId, row.status);
  876. })
  877. .then(() => {
  878. this.msgSuccess(text + "成功");
  879. })
  880. .catch(function () {
  881. row.status = row.status === "0" ? "1" : "0";
  882. });
  883. },
  884. // 取消按钮
  885. cancel() {
  886. this.open = false;
  887. this.reset();
  888. },
  889. cancelBind(){
  890. this.bindCompanyOpen=false;
  891. this.resetBindCompany();
  892. },
  893. submitFormArea(address){
  894. const uIds = this.ids;
  895. if (address == null){
  896. this.$message.error("请选择地区");
  897. return;
  898. }
  899. updateCompanyUserAreaList({userIds:uIds,addressId:address}).then(res=>{
  900. this.companyUserArea.open=false;
  901. this.getList();
  902. this.msgSuccess("操作成功");
  903. })
  904. },
  905. cancelArea(){
  906. this.companyUserArea.open=false;
  907. this.addressId=null;
  908. },
  909. qwCancel() {
  910. this.qwOpen = false;
  911. this.qwUserId=null;
  912. },
  913. handerCompanyUserAreaList(){
  914. this.companyUserArea.open=true;
  915. },
  916. // 表单重置
  917. reset() {
  918. this.form = {
  919. userId: undefined,
  920. deptId: undefined,
  921. userName: undefined,
  922. nickName: undefined,
  923. password: undefined,
  924. idCard: undefined,
  925. phonenumber: undefined,
  926. userType: "01",
  927. email: undefined,
  928. sex: undefined,
  929. status: "0",
  930. remark: undefined,
  931. domain: null,
  932. postIds: [],
  933. roleIds: [],
  934. };
  935. this.resetForm("form");
  936. },
  937. resetBindCompany() {
  938. this.formBindCompany = {
  939. deptId: null,
  940. addressId: null,
  941. roleIds: [],
  942. };
  943. this.resetForm("formBindCompany");
  944. },
  945. /** 搜索按钮操作 */
  946. handleQuery() {
  947. this.queryParams.page = 1;
  948. this.getList();
  949. },
  950. /** 重置按钮操作 */
  951. resetQuery() {
  952. this.dateRange = [];
  953. this.resetForm("queryForm");
  954. this.handleQuery();
  955. },
  956. // 多选框选中数据
  957. handleSelectionChange(selection) {
  958. this.ids = selection.map((item) => item.userId);
  959. this.single = selection.length != 1;
  960. this.multiple = !selection.length;
  961. },
  962. /** 新增按钮操作 */
  963. handleAdd() {
  964. this.reset();
  965. this.getTreeselect();
  966. getUser().then((response) => {
  967. this.postOptions = response.posts;
  968. this.roleOptions = response.roles;
  969. this.open = true;
  970. this.title = "添加员工";
  971. this.form.password = this.form1.loginPassword;
  972. console.log(" this.form1 ", this.form1)
  973. });
  974. },
  975. handleBindCompanyUserCode(){
  976. this.reset();
  977. this.getTreeselect();
  978. getUser().then((response) => {
  979. this.postOptions = response.posts;
  980. this.roleOptions = response.roles;
  981. this.bindCompanyOpen = true;
  982. this.title = "创建 新增/绑定销售 的二维码";
  983. });
  984. },
  985. qwBind(row){
  986. this.qwUser=[];
  987. this.qwUserList=[];
  988. this.qwForm.companyUserId=row.userId
  989. getUser(row.userId).then((response) => {
  990. if(response.data.qwUserId!=null){
  991. this.qwUser=((response.data.qwUserId).split(",").map(Number))
  992. getQwUserByIds(this.qwUser).then(res => {
  993. this.qwUserList=res.data;
  994. })
  995. // this.qwUser.forEach(item => {
  996. // getQwUser(item).then(response => {
  997. // this.qwUserList.push(response.data);
  998. // });
  999. // });
  1000. }
  1001. this.qwOpen = true;
  1002. });
  1003. },
  1004. bindQwUser(row){
  1005. this.user.open=false;
  1006. if (!this.qwUserList.some(item => item.id == row.id)) {
  1007. this.qwUserList.push(row)
  1008. }
  1009. if (!this.qwUser.some(item => item == row.id)) {
  1010. this.qwUser.push(row.id);
  1011. }
  1012. },
  1013. /** 修改按钮操作 */
  1014. handleUpdate(row) {
  1015. this.reset();
  1016. this.getTreeselect();
  1017. const userId = row.userId || this.ids;
  1018. getUser(userId).then((response) => {
  1019. this.form = response.data;
  1020. this.postOptions = response.posts;
  1021. this.roleOptions = response.roles;
  1022. this.form.postIds = response.postIds;
  1023. this.form.roleIds = response.roleIds;
  1024. this.open = true;
  1025. this.title = "修改员工";
  1026. this.form.password = "";
  1027. });
  1028. },
  1029. /** 重置密码按钮操作 */
  1030. handleResetPwd(row) {
  1031. this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
  1032. confirmButtonText: "确定",
  1033. cancelButtonText: "取消",
  1034. inputPlaceholder: "8-20 位,包含字母、数字和特殊字符",
  1035. inputValidator: (value) => {
  1036. const pattern = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,20}/;
  1037. const hasChinese = /[\u4e00-\u9fa5]/.test(value);
  1038. const hasFullWidth = /[!-~]/.test(value);
  1039. if (hasChinese) return '不能包含中文字符';
  1040. if (hasFullWidth) return '不能包含全角符号,请使用英文输入法';
  1041. if (!pattern.test(value)) return '密码格式错误:需包含字母、数字和英文特殊字符,长度为 8-20 位';
  1042. return true;
  1043. }
  1044. })
  1045. .then(({ value }) => {
  1046. resetUserPwd(row.userId, value).then((response) => {
  1047. if (response.code === 200) {
  1048. this.msgSuccess("修改成功,新密码是:" + value);
  1049. }
  1050. });
  1051. })
  1052. .catch(() => {});
  1053. },
  1054. /** 提交按钮 */
  1055. submitForm: function () {
  1056. // this.onDomainBlur();
  1057. // const domainPattern = /^http:\/\/([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
  1058. // if (this.form.domain!=null && !domainPattern.test(this.form.domain)) {
  1059. // this.$message.error('请输入正确格式的域名,如:http://xxx.xxx.com');
  1060. // return;
  1061. // }
  1062. this.$refs["form"].validate((valid) => {
  1063. if (valid) {
  1064. if (this.form.userId != undefined) {
  1065. updateUser(this.form).then((response) => {
  1066. if (response.code === 200) {
  1067. this.msgSuccess("修改成功");
  1068. this.open = false;
  1069. this.getList();
  1070. }
  1071. });
  1072. } else {
  1073. addUser(this.form).then((response) => {
  1074. if (response.code === 200) {
  1075. this.msgSuccess("新增成功");
  1076. this.open = false;
  1077. this.getList();
  1078. }
  1079. });
  1080. }
  1081. }
  1082. });
  1083. },
  1084. downloadImage(imageSrc, fileName) {
  1085. const link = document.createElement('a');
  1086. link.href = imageSrc;
  1087. link.download = fileName || '绑定或新增销售.png';
  1088. document.body.appendChild(link);
  1089. link.click();
  1090. document.body.removeChild(link);
  1091. },
  1092. submitBingCompanyForm: function () {
  1093. this.$refs["formBindCompany"].validate((valid) => {
  1094. if (valid) {
  1095. let loadingRock = this.$loading({
  1096. lock: true,
  1097. text: '生成二维码中~~请不要刷新页面!!',
  1098. spinner: 'el-icon-loading',
  1099. background: 'rgba(0, 0, 0, 0.7)'
  1100. });
  1101. addCodeUrl(this.formBindCompany).then((response) => {
  1102. this.bindCompanyOpen=false;
  1103. this.bindCompanyUrl.url=response.data.url
  1104. this.bindCompanyUrl.open=true;
  1105. this.bindCompanyUrl.name="绑定或新增 销售二维码";
  1106. }).finally(res=>{
  1107. loadingRock.close();
  1108. })
  1109. }
  1110. });
  1111. },
  1112. /**
  1113. * 同步企业微信员工
  1114. */
  1115. synSubmitForm() {
  1116. this.synOpen=false;
  1117. this.loading=true;
  1118. /*this.msgSuccess("");
  1119. let loadingRock = this.$loading({
  1120. lock: true,
  1121. text: '同步中.....请等待.....请不要重复点击!!',
  1122. spinner: 'el-icon-loading',
  1123. background: 'rgba(0, 0, 0, 0.7)'
  1124. });*/
  1125. addQwUser(this.synform.corpId).then(response => {
  1126. //this.msgSuccess("同步成功");
  1127. this.msgSuccess("正在同步中...");
  1128. this.getList();
  1129. this.synOpen=false;
  1130. }).finally(()=>{
  1131. this.loading=false;
  1132. this.synOpen=false;
  1133. //loadingRock.close();
  1134. });
  1135. },
  1136. synNameSubmitForm() {
  1137. this.synNameOpen=false;
  1138. this.loading=true;
  1139. addQwUserName(this.synNameform.corpId).then(response => {
  1140. // this.msgSuccess("同步成功");
  1141. this.msgSuccess("正在同步中...");
  1142. this.getList();
  1143. this.synNameOpen=false;
  1144. }).finally(()=>{
  1145. this.loading=false;
  1146. this.synNameOpen=false;
  1147. //loadingRock.close();
  1148. });
  1149. },
  1150. /**
  1151. * 同步企业微信部门
  1152. */
  1153. qwSyncDept(){
  1154. syncDept().then(response => {
  1155. this.msgSuccess("同步成功");
  1156. this.getList();
  1157. }).catch(()=>{
  1158. this.msgError("同步失败:"+response.msg);
  1159. })
  1160. },
  1161. qwSubmitForm(){
  1162. let loadingRock = this.$loading({
  1163. lock: true,
  1164. text: '绑定中.....同步客户信息中.....',
  1165. spinner: 'el-icon-loading',
  1166. background: 'rgba(0, 0, 0, 0.7)'
  1167. });
  1168. this.qwForm.id = (this.qwUser).join(',');
  1169. bindQwUser(this.qwForm).then(response => {
  1170. this.msgSuccess("绑定成功");
  1171. this.qwOpen = false;
  1172. this.getList();
  1173. this.qwUserId=null;
  1174. this.qwUser=[];
  1175. }).finally(res=>{
  1176. loadingRock.close()
  1177. });
  1178. },
  1179. /** 删除按钮操作 */
  1180. handleDelete(row) {
  1181. const userIds = row.userId || this.ids;
  1182. this.$confirm(
  1183. '是否确认删除员工编号为"' + userIds + '"的数据项?【注意:删除后绑定的企业微信相关信息可能会错乱!!】',
  1184. "警告",
  1185. {
  1186. confirmButtonText: "确定",
  1187. cancelButtonText: "取消",
  1188. type: "warning",
  1189. }
  1190. )
  1191. .then(function () {
  1192. return delUser(userIds);
  1193. })
  1194. .then(() => {
  1195. this.getList();
  1196. this.msgSuccess("删除成功");
  1197. })
  1198. .catch(function () {});
  1199. },
  1200. /** 导出按钮操作 */
  1201. handleExport() {
  1202. const queryParams = this.queryParams;
  1203. this.$confirm("是否确认导出所有用户数据项?", "警告", {
  1204. confirmButtonText: "确定",
  1205. cancelButtonText: "取消",
  1206. type: "warning",
  1207. })
  1208. .then(function () {
  1209. return exportUser(queryParams);
  1210. })
  1211. .then((response) => {
  1212. this.download(response.msg);
  1213. })
  1214. .catch(function () {});
  1215. },
  1216. /** 导入按钮操作 */
  1217. handleImport() {
  1218. this.upload.title = "用户导入";
  1219. this.upload.open = true;
  1220. },
  1221. /** 下载模板操作 */
  1222. importTemplate() {
  1223. importTemplate().then((response) => {
  1224. this.download(response.msg);
  1225. });
  1226. },
  1227. // 文件上传中处理
  1228. handleFileUploadProgress(event, file, fileList) {
  1229. this.upload.isUploading = true;
  1230. },
  1231. // 文件上传成功处理
  1232. handleFileSuccess(response, file, fileList) {
  1233. this.upload.open = false;
  1234. this.upload.isUploading = false;
  1235. this.$refs.upload.clearFiles();
  1236. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  1237. this.getList();
  1238. },
  1239. // 提交上传文件
  1240. submitFileForm() {
  1241. this.$refs.upload.submit();
  1242. },
  1243. generateDomain(){
  1244. let queryParams;
  1245. if(this.form.userId){
  1246. queryParams= {
  1247. 'userId': this.form.userId,
  1248. }
  1249. }
  1250. generateSubDomain(queryParams).then(response => {
  1251. this.form.domain=response.data
  1252. });
  1253. },
  1254. /** 设置单独注册会员按钮操作 */
  1255. handleSetRegister() {
  1256. this.registerOpen = true;
  1257. this.registerForm.status = false;
  1258. },
  1259. /** 提交设置单独注册会员 */
  1260. submitRegisterForm() {
  1261. setIsRegisterMember({status: this.registerForm.status}, this.ids).then(response => {
  1262. if (response.code === 200) {
  1263. this.msgSuccess("设置成功");
  1264. this.registerOpen = false;
  1265. this.getList();
  1266. }
  1267. });
  1268. },
  1269. /** 开关是否允许所有方式注册会员 */
  1270. handleAllowedAllRegister() {
  1271. this.allowedAllRegisterOpen = true;
  1272. // this.allowedAllRegisterForm.status = true;
  1273. },
  1274. // 提交
  1275. submitAllowedAllRegisterForm(){
  1276. isAllowedAllRegister({status: this.allowedAllRegisterForm.status}, this.ids).then(response => {
  1277. if (response.code === 200) {
  1278. this.msgSuccess("操作成功");
  1279. this.allowedAllRegisterOpen = false;
  1280. this.getList();
  1281. }
  1282. });
  1283. },
  1284. /**
  1285. * 上传文件之前的钩子,参数为上传的文件,若返回 false 或者返回 Promise且被 reject,则停止上传。
  1286. * @param {File} file - 用户选择的文件对象
  1287. * @param {Object} row - 当前行的数据对象
  1288. */
  1289. beforeImageUpload(file, row) {
  1290. // 清除之前的错误信息
  1291. this.$set(row, 'uploadError', '');
  1292. const isJPG = file.type === 'image/jpeg';
  1293. const isPNG = file.type === 'image/png';
  1294. const isGIF = file.type === 'image/gif'; // 根据需要添加更多格式
  1295. const isValidFormat = isJPG || isPNG || isGIF;
  1296. const isLt2M = file.size / 1024 / 1024 < 2; // 限制图片大小为 2MB
  1297. if (!isValidFormat) {
  1298. const errorMsg = '上传二维码图片只能是 JPG/PNG/GIF 格式!';
  1299. this.$message.error(errorMsg);
  1300. this.$set(row, 'uploadError', errorMsg); // 在行内显示错误
  1301. return false;
  1302. }
  1303. if (!isLt2M) {
  1304. const errorMsg = '上传二维码图片大小不能超过 2MB!';
  1305. this.$message.error(errorMsg);
  1306. this.$set(row, 'uploadError', errorMsg); // 在行内显示错误
  1307. return false;
  1308. }
  1309. return true; // 校验通过,允许上传
  1310. },
  1311. /**
  1312. * 自定义上传方法
  1313. * @param {Object} options - Element UI upload 组件传递的参数,包含 file, onSuccess, onError, onProgress 等
  1314. * @param {Object} row - 当前行的数据对象
  1315. */
  1316. async handleCustomUpload(options, row) {
  1317. const file = options.file;
  1318. const formData = new FormData();
  1319. formData.append('file', file);
  1320. formData.append('userId',row.userId)
  1321. this.$set(row, 'uploading', true);
  1322. this.$set(row, 'uploadError', '');
  1323. try {
  1324. const response = await axios.post(this.uploadUrl, formData, {
  1325. headers: {
  1326. 'Content-Type': 'multipart/form-data',
  1327. },
  1328. onUploadProgress: progressEvent => {
  1329. const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
  1330. console.log(`上传进度: ${percentCompleted}%`);
  1331. }
  1332. });
  1333. if (response.data && (response.data.url || (response.data.data && response.data.data.url))) {
  1334. const imageUrl = response.data.url || response.data.data.url;
  1335. this.$set(row, 'qrCodeWeixin', imageUrl); // 更新行数据中的图片URL
  1336. this.$message.success('图片上传成功!');
  1337. options.onSuccess(response.data, file); // 通知el-upload上传成功 (虽然我们自定义了,但调用一下也无妨)
  1338. } else {
  1339. const errorMsg = response.data.message || '图片上传失败,服务器未返回有效URL';
  1340. this.$message.error(errorMsg);
  1341. this.$set(row, 'uploadError', errorMsg);
  1342. options.onError(new Error(errorMsg), file); // 通知el-upload上传失败
  1343. }
  1344. } catch (error) {
  1345. console.error('上传失败:', error);
  1346. let errorMsg = '图片上传失败';
  1347. if (error.response && error.response.data && error.response.data.message) {
  1348. errorMsg = error.response.data.message;
  1349. } else if (error.message) {
  1350. errorMsg = error.message;
  1351. }
  1352. this.$message.error(errorMsg);
  1353. this.$set(row, 'uploadError', errorMsg);
  1354. options.onError(error, file); // 通知el-upload上传失败
  1355. } finally {
  1356. this.$set(row, 'uploading', false); // 无论成功失败,结束上传状态
  1357. }
  1358. },
  1359. requestUpload() {
  1360. },
  1361. beforeUpload(){
  1362. console.log(file.type)
  1363. const isPic =
  1364. file.type === 'image/jpeg' ||
  1365. file.type === 'image/png' ||
  1366. file.type === 'image/gif' ||
  1367. file.type === 'image/jpg' ||
  1368. file.type === 'audio/mpeg'
  1369. const isLt2M = file.size / 1024 / 1024 < 2
  1370. if (!isPic) {
  1371. this.$message.error('上传图片只能是 JPG、JPEG、PNG、GIF 格式!')
  1372. return false
  1373. }
  1374. if (!isLt2M) {
  1375. this.$message.error('上传头像图片大小不能超过 2MB!')
  1376. }
  1377. return isPic && isLt2M
  1378. },
  1379. handleUpdateDoctor(row){
  1380. this.doctor.title="绑定医生"
  1381. this.doctor.open=true;
  1382. this.doctorForm.userId=row.userId;
  1383. },
  1384. bindCompanyUserDoctorId(row){
  1385. console.log(row)
  1386. this.doctorForm.doctorId=row;
  1387. bindDoctorId(this.doctorForm).then(res=>{
  1388. if (res.code==200){
  1389. this.$message.success('绑定成功')
  1390. }else {
  1391. this.$message.error('绑定失败:',res.msg)
  1392. }
  1393. this.getList()
  1394. this.doctor.open=false;
  1395. })
  1396. },
  1397. handleUnBindUserId(val){
  1398. this.$confirm(
  1399. '确认解绑医生:<span style="color: green;">' + val.nickName + '' +
  1400. '</span> 的医生?',
  1401. {
  1402. confirmButtonText: "确定",
  1403. cancelButtonText: "取消",
  1404. type: "warning",
  1405. dangerouslyUseHTMLString: true // 允许使用 HTML 字符串
  1406. }
  1407. ).then(() => {
  1408. return unBindDoctorId(val.userId);
  1409. }).then(response => {
  1410. this.getList();
  1411. this.msgSuccess("解绑成功");
  1412. }).finally(res=>{
  1413. this.getList();
  1414. })
  1415. },
  1416. },
  1417. };
  1418. </script>