index.vue 58 KB

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