index.vue 56 KB

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