index.vue 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575
  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. <el-dialog title="设置单独注册会员" :visible.sync="registerOpen" width="400px" append-to-body>
  533. <el-form ref="registerForm" :model="registerForm" label-width="180px">
  534. <el-form-item label="是否需要开启单独注册">
  535. <el-switch v-model="registerForm.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="submitRegisterForm">确 定</el-button>
  540. <el-button @click="registerOpen = false">取 消</el-button>
  541. </div>
  542. </el-dialog>
  543. <!-- 是否允许所有方式注册会员弹窗 -->
  544. <el-dialog title="允许注册会员" :visible.sync="allowedAllRegisterOpen" width="400px" append-to-body>
  545. <el-form ref="registerForm" :model="allowedAllRegisterForm" label-width="180px">
  546. <el-form-item label="是否允许注册会员">
  547. <el-switch v-model="allowedAllRegisterForm.status" active-value="true" inactive-value="false"></el-switch>
  548. </el-form-item>
  549. </el-form>
  550. <div slot="footer" class="dialog-footer">
  551. <el-button type="primary" @click="submitAllowedAllRegisterForm">确 定</el-button>
  552. <el-button @click="allowedAllRegisterOpen = false">取 消</el-button>
  553. </div>
  554. </el-dialog>
  555. <el-dialog :title="bindCompanyUrl.title" v-if="bindCompanyUrl.open" :visible.sync="bindCompanyUrl.open" width="450px" append-to-body>
  556. <div style="padding-bottom:15px;" >
  557. <img :src="bindCompanyUrl.url" width="400px">
  558. </div>
  559. <div slot="footer" class="dialog-footer">
  560. <el-button @click="downloadImage(bindCompanyUrl.url, bindCompanyUrl.name+'.png')">下载二维码</el-button>
  561. </div>
  562. </el-dialog>
  563. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  564. <el-upload
  565. ref="upload"
  566. :limit="1"
  567. accept=".xlsx, .xls"
  568. :headers="upload.headers"
  569. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  570. :disabled="upload.isUploading"
  571. :on-progress="handleFileUploadProgress"
  572. :on-success="handleFileSuccess"
  573. :auto-upload="false"
  574. drag
  575. >
  576. <i class="el-icon-upload"></i>
  577. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  578. <div class="el-upload__tip text-center" slot="tip">
  579. <div class="el-upload__tip" slot="tip">
  580. </div>
  581. <span>仅允许导入xls、xlsx格式文件。</span>
  582. <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
  583. </div>
  584. </el-upload>
  585. <div slot="footer" class="dialog-footer">
  586. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  587. <el-button @click="upload.open = false">取 消</el-button>
  588. </div>
  589. </el-dialog>
  590. <el-dialog :title="doctor.title" :visible.sync="doctor.open" width="800px" append-to-body>
  591. <selectDoctor ref="selectDoctor" @bindCompanyUserDoctorId="bindCompanyUserDoctorId"></selectDoctor>
  592. </el-dialog>
  593. </div>
  594. </template>
  595. <script>
  596. import {
  597. qwList,
  598. delUser,
  599. addUser,
  600. getUser,
  601. updateUser,
  602. exportUser,
  603. resetUserPwd,
  604. importTemplate,
  605. getCitysAreaList,
  606. changeUserStatus,
  607. generateSubDomain,
  608. setIsRegisterMember,
  609. updateCompanyUserAreaList,
  610. isAllowedAllRegister, unBindDoctorId, bindDoctorId,updateBatchUserRoles
  611. } from "@/api/company/companyUser";
  612. import { getToken } from "@/utils/auth";
  613. import { treeselect } from "@/api/company/companyDept";
  614. import Treeselect from "@riophae/vue-treeselect";
  615. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  616. import {bindQwUser, getQwUserList, addQwUser, getQwUser, getQwUserByIds,addQwUserName} from '@/api/qw/user';
  617. import { syncDept } from '@/api/qw/qwDept';
  618. import { getMyQwUserList,getMyQwCompanyList } from "@/api/qw/user";
  619. import selectUser from "@/views/company/components/selectQwUser.vue";
  620. import { getConfigByKey } from "@/api/company/companyConfig";
  621. import axios from "axios";
  622. import {addCodeUrl} from "../../../api/company/companyUser";
  623. import selectDoctor from "@/views/qw/user/selectDoctor.vue";
  624. export default {
  625. name: "User",
  626. components: {selectDoctor, Treeselect ,selectUser},
  627. data() {
  628. return {
  629. doctor: {
  630. open: false,
  631. title: '绑定医生'
  632. },
  633. doctorForm: {
  634. userId: null,
  635. doctorId: null
  636. },
  637. uploadUrl: process.env.VUE_APP_BASE_API+"/company/user/common/uploadOSS",
  638. // 遮罩层
  639. loading: false,
  640. qwUserList:[],
  641. qwUserId:[],
  642. myQwCompanyList:[],
  643. qwUser:[],
  644. user:{
  645. open:false,
  646. title:"搜索企业"
  647. },
  648. // 选中数组
  649. ids: [],
  650. synform:{corpId:null},
  651. synOpen:false,
  652. synNameform:{corpId:null},
  653. synNameOpen:false,
  654. // 非单个禁用
  655. single: true,
  656. // 非多个禁用
  657. multiple: true,
  658. // 显示搜索条件
  659. showSearch: true,
  660. // 总条数
  661. total: 0,
  662. // 用户表格数据
  663. userList: null,
  664. // 弹出层标题
  665. title: "",
  666. // 部门树选项
  667. deptOptions: undefined,
  668. // 是否显示弹出层
  669. open: false,
  670. bindCompanyOpen: false,
  671. qwOpen:false,
  672. // 部门名称
  673. deptName: undefined,
  674. // 日期范围
  675. dateRange: [],
  676. // 状态数据字典
  677. statusOptions: [],
  678. // 性别状态字典
  679. sexOptions: [],
  680. // 岗位选项
  681. postOptions: [],
  682. // 角色选项
  683. roleOptions: [],
  684. userTypeOptions:[
  685. { "dictLabel": "临时管理员","dictValue": "02"},
  686. { "dictLabel": "普通用户","dictValue": "01"}
  687. ],
  688. qwForm:{
  689. id:null,
  690. companyUserId:null,
  691. },
  692. companyUserArea:{
  693. open:false,
  694. title:"分配区域",
  695. },
  696. //选择的区域
  697. addressId:null,
  698. citysAreaList:[],
  699. // 表单参数
  700. form: {},
  701. formBindCompany: {},
  702. bindCompanyUrl:{
  703. open:false,
  704. title:"绑定/注册销售二维码",
  705. name:null,
  706. url:null,
  707. },
  708. form1: {},
  709. defaultProps: {
  710. children: "children",
  711. label: "label",
  712. },
  713. // 用户导入参数
  714. upload: {
  715. // 是否显示弹出层(用户导入)
  716. open: false,
  717. // 弹出层标题(用户导入)
  718. title: "",
  719. // 是否禁用上传
  720. isUploading: false,
  721. // 是否更新已经存在的用户数据
  722. updateSupport: 0,
  723. // 设置上传的请求头部
  724. headers: { Authorization: "Bearer " + getToken() },
  725. // 上传的地址
  726. url: process.env.VUE_APP_BASE_API + "/company/user/importCompanyUser",
  727. },
  728. // 查询参数
  729. queryParams: {
  730. pageNum: 1,
  731. pageSize: 10,
  732. userName: null,
  733. phonenumber: null,
  734. status: null,
  735. deptId: null,
  736. qwStatus:null,
  737. },
  738. qwStatusOptions:[],
  739. registerOpen: false,
  740. registerForm: {
  741. status: false
  742. },
  743. // 表单校验
  744. rules: {
  745. userName: [
  746. { required: true, message: "员工工号不能为空", trigger: "blur" },
  747. ],
  748. nickName: [
  749. { required: true, message: "员工姓名不能为空", trigger: "blur" },
  750. ],
  751. deptId: [
  752. { required: true, message: "归属部门不能为空", trigger: "blur" },
  753. ],
  754. addressId: [
  755. { required: true, message: "销售所属区域不能为空", trigger: "blur" },
  756. ],
  757. password: [
  758. { required: true, message: "员工密码不能为空", trigger: "blur" },
  759. {
  760. pattern: /^(?=.*[A-Za-z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,20}$/,
  761. message: "密码长度为 8-20 位,必须包含字母、数字和特殊字符",
  762. trigger: ["blur", "change"],
  763. }
  764. ],
  765. idCard: [
  766. { required: true, message: "身份证号不能为空", trigger: "blur" },
  767. ],
  768. // email: [
  769. // { required: true, message: "邮箱地址不能为空", trigger: "blur" },
  770. // {
  771. // type: "email",
  772. // message: "'请输入正确的邮箱地址",
  773. // trigger: ["blur", "change"],
  774. // },
  775. // ],
  776. phonenumber: [
  777. { required: true, message: "手机号码不能为空", trigger: "blur" },
  778. {
  779. pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
  780. message: "请输入正确的手机号码",
  781. trigger: "blur",
  782. },
  783. ],
  784. },
  785. // 表单校验
  786. bindCompanyRules: {
  787. deptId: [
  788. { required: true, message: "归属部门不能为空", trigger: "blur" },
  789. ],
  790. addressId: [
  791. { required: true, message: "销售所属区域不能为空", trigger: "blur" },
  792. ],
  793. roleIds: [
  794. { required: true, message: "角色不能为空", trigger: "blur" },
  795. ],
  796. corpId: [
  797. { required: true, message: "角色不能为空", trigger: "blur" },
  798. ],
  799. },
  800. // 是否允许注册会员开关
  801. allowedAllRegisterOpen: false,
  802. allowedAllRegisterForm: {
  803. status: true
  804. },
  805. // 在 data() 中添加
  806. batchRoleDialogVisible: false,
  807. selectedRoleIds: [],
  808. batchRoleForm: {
  809. userIds: [],
  810. roleIds: []
  811. },
  812. };
  813. },
  814. watch: {
  815. // 根据名称筛选部门树
  816. deptName(val) {
  817. this.$refs.tree.filter(val);
  818. },
  819. },
  820. created() {
  821. this.getList();
  822. this.getTreeselect();
  823. this.getDicts("sys_normal_disable").then((response) => {
  824. this.statusOptions = response.data;
  825. });
  826. this.getDicts("company_user_sex").then((response) => {
  827. this.sexOptions = response.data;
  828. });
  829. this.getDicts("sys_qw_user_status").then(response => {
  830. this.qwStatusOptions = response.data;
  831. });
  832. getConfigByKey("his.login").then(response => {
  833. this.form1 =JSON.parse(response.data.configValue);
  834. });
  835. getCitysAreaList().then(res=>{
  836. this.citysAreaList=res.data;
  837. })
  838. getMyQwCompanyList().then(response => {
  839. this.myQwCompanyList = response.data;
  840. });
  841. },
  842. methods: {
  843. onDomainBlur() {
  844. if (this.form.domain != null) {
  845. let value = this.form.domain.trim();
  846. // 强制只保留第一个 http://
  847. const httpCount = (value.match(/http:\/\//g) || []).length;
  848. if (httpCount > 1) {
  849. value = value.replace(/(http:\/\/)+/, 'http://'); // 只留第一个
  850. }
  851. // 如果不是 http:// 开头,自动补充
  852. if (!value.startsWith('http://')) {
  853. value = 'http://' + value.replace(/^https?:\/\//, ''); // 去掉其他 http(s):// 再补
  854. }
  855. this.form.domain = value; // 重新赋值,保证输入正确
  856. // 正则校验最终格式,提醒用户
  857. const domainPattern = /^http:\/\/([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
  858. if (!domainPattern.test(this.form.domain)) {
  859. return this.$message.error('请输入正确格式的域名,如:http://xxx.xxx.com');
  860. }
  861. }
  862. },
  863. // 添加处理 selectUser 关闭的方法
  864. handleSelectUserClose() {
  865. this.user.open = false
  866. // 如果 selectUser 组件有 clearSelection 方法,也可以调用
  867. if (this.$refs.selectUser && typeof this.$refs.selectUser.clearSelection === 'function') {
  868. this.$refs.selectUser.clearSelection()
  869. }
  870. },
  871. // edit G start
  872. // 修改 selectQwUser 方法
  873. selectQwUser() {
  874. this.user.open = true;
  875. // 在下次DOM更新后设置已选中的项
  876. this.$nextTick(() => {
  877. if (this.$refs.selectUser && this.qwUserList.length > 0) {
  878. // 将已选中的用户传递给子组件
  879. this.$refs.selectUser.setSelectedUsers(this.qwUserList);
  880. }
  881. });
  882. },
  883. // 修改 bindQwUser 方法
  884. bindQwUser(row) {
  885. // this.user.open = false; // 暂时注释掉这行,改为在 handleBatchBind 中处理
  886. if (!this.qwUserList.some(item => item.id == row.id)) {
  887. this.qwUserList.push(row)
  888. }
  889. if (!this.qwUser.some(item => item == row.id)) {
  890. this.qwUser.push(row.id)
  891. }
  892. },
  893. // 修改 qwBind 方法
  894. qwBind(row) {
  895. this.qwUser = [];
  896. this.qwUserList = [];
  897. this.qwForm.companyUserId = row.userId;
  898. getUser(row.userId).then((response) => {
  899. if (response.data.qwUserId != null) {
  900. // 保存已绑定的企微用户ID列表
  901. this.qwUser = ((response.data.qwUserId).split(",").map(Number));
  902. getQwUserByIds(this.qwUser).then(res => {
  903. this.qwUserList = res.data;
  904. });
  905. }
  906. // 先打开"绑定企微账号"对话框
  907. this.qwOpen = true;
  908. });
  909. },
  910. // 在 methods 中添加批量修改角色的方法
  911. batchEditRole() {
  912. if (this.ids.length === 0) {
  913. this.$message.warning("请至少选择一个用户");
  914. return;
  915. }
  916. // 获取角色列表数据
  917. getUser().then((response) => {
  918. this.roleOptions = response.roles;
  919. this.batchRoleDialogVisible = true;
  920. this.selectedRoleIds = []; // 清空之前的选择
  921. });
  922. },
  923. // 添加批量角色更新提交方法
  924. submitBatchRoles() {
  925. // 验证选择的角色
  926. if (!this.selectedRoleIds || this.selectedRoleIds.length === 0) {
  927. this.$message.warning("请至少选择一个角色");
  928. return;
  929. }
  930. console.log(this.ids)
  931. console.log(this.selectedRoleIds)
  932. // 调用API批量更新用户角色
  933. updateBatchUserRoles({ userIds: this.ids, roleIds: this.selectedRoleIds })
  934. .then(response => {
  935. if (response.code === 200) {
  936. this.$message.success("批量修改角色成功");
  937. this.batchRoleDialogVisible = false;
  938. this.getList(); // 刷新列表
  939. }
  940. });
  941. },
  942. // edit G end
  943. /** 查询用户列表 */
  944. getList() {
  945. this.loading = true;
  946. qwList(this.addDateRange(this.queryParams, this.dateRange)).then(
  947. (response) => {
  948. this.userList = response.rows;
  949. this.total = response.total;
  950. this.loading = false;
  951. console.log(" this.userList ", this.userList)
  952. }
  953. );
  954. },
  955. handleClosegroupUser(list) {
  956. const index = this.qwUser.findIndex(t => t === list);
  957. if (index !== -1) {
  958. this.qwUser.splice(index, 1);
  959. }
  960. },
  961. /** 查询部门下拉树结构 */
  962. getTreeselect() {
  963. treeselect().then((response) => {
  964. this.deptOptions = response.data;
  965. });
  966. },
  967. // 筛选节点
  968. filterNode(value, data) {
  969. if (!value) return true;
  970. return data.label.indexOf(value) !== -1;
  971. },
  972. // 节点单击事件
  973. handleNodeClick(data) {
  974. this.queryParams.deptId = data.id;
  975. this.getList();
  976. },
  977. // 用户状态修改
  978. handleStatusChange(row) {
  979. let text = row.status === "0" ? "启用" : "停用";
  980. this.$confirm(
  981. '确认要"' + text + '""' + row.userName + '"用户吗?',
  982. "警告",
  983. {
  984. confirmButtonText: "确定",
  985. cancelButtonText: "取消",
  986. type: "warning",
  987. }
  988. )
  989. .then(function() {
  990. return changeUserStatus(row.userId, row.status);
  991. })
  992. .then(() => {
  993. this.msgSuccess(text + "成功");
  994. })
  995. .catch(function() {
  996. row.status = row.status === "0" ? "1" : "0";
  997. });
  998. },
  999. // 取消按钮
  1000. cancel() {
  1001. this.open = false;
  1002. this.reset();
  1003. },
  1004. cancelBind() {
  1005. this.bindCompanyOpen = false;
  1006. this.resetBindCompany();
  1007. },
  1008. submitFormArea(address) {
  1009. const uIds = this.ids;
  1010. if (address == null) {
  1011. this.$message.error("请选择地区");
  1012. return;
  1013. }
  1014. updateCompanyUserAreaList({ userIds: uIds, addressId: address }).then(res => {
  1015. this.companyUserArea.open = false;
  1016. this.getList();
  1017. this.msgSuccess("操作成功");
  1018. })
  1019. },
  1020. cancelArea() {
  1021. this.companyUserArea.open = false;
  1022. this.addressId = null;
  1023. },
  1024. qwCancel() {
  1025. this.qwOpen = false;
  1026. this.qwUserId = null;
  1027. },
  1028. handerCompanyUserAreaList() {
  1029. this.companyUserArea.open = true;
  1030. },
  1031. // 表单重置
  1032. reset() {
  1033. this.form = {
  1034. userId: undefined,
  1035. deptId: undefined,
  1036. userName: undefined,
  1037. nickName: undefined,
  1038. password: undefined,
  1039. idCard: undefined,
  1040. phonenumber: undefined,
  1041. userType: "01",
  1042. email: undefined,
  1043. sex: undefined,
  1044. status: "0",
  1045. remark: undefined,
  1046. domain: null,
  1047. postIds: [],
  1048. roleIds: [],
  1049. };
  1050. this.resetForm("form");
  1051. },
  1052. resetBindCompany() {
  1053. this.formBindCompany = {
  1054. deptId: null,
  1055. addressId: null,
  1056. roleIds: [],
  1057. };
  1058. this.resetForm("formBindCompany");
  1059. },
  1060. /** 搜索按钮操作 */
  1061. handleQuery() {
  1062. this.queryParams.page = 1;
  1063. this.getList();
  1064. },
  1065. /** 重置按钮操作 */
  1066. resetQuery() {
  1067. this.dateRange = [];
  1068. this.resetForm("queryForm");
  1069. this.handleQuery();
  1070. },
  1071. // 多选框选中数据
  1072. handleSelectionChange(selection) {
  1073. this.ids = selection.map((item) => item.userId);
  1074. this.single = selection.length != 1;
  1075. this.multiple = !selection.length;
  1076. },
  1077. /** 新增按钮操作 */
  1078. handleAdd() {
  1079. this.reset();
  1080. this.getTreeselect();
  1081. getUser().then((response) => {
  1082. this.postOptions = response.posts;
  1083. this.roleOptions = response.roles;
  1084. this.open = true;
  1085. this.title = "添加员工";
  1086. this.form.password = this.form1.loginPassword;
  1087. console.log(" this.form1 ", this.form1)
  1088. });
  1089. },
  1090. handleBindCompanyUserCode() {
  1091. this.reset();
  1092. this.getTreeselect();
  1093. getUser().then((response) => {
  1094. this.postOptions = response.posts;
  1095. this.roleOptions = response.roles;
  1096. this.bindCompanyOpen = true;
  1097. this.title = "创建 新增/绑定销售 的二维码";
  1098. });
  1099. },
  1100. /** 修改按钮操作 */
  1101. handleUpdate(row) {
  1102. this.reset();
  1103. this.getTreeselect();
  1104. const userId = row.userId || this.ids;
  1105. getUser(userId).then((response) => {
  1106. this.form = response.data;
  1107. this.postOptions = response.posts;
  1108. this.roleOptions = response.roles;
  1109. this.form.postIds = response.postIds;
  1110. this.form.roleIds = response.roleIds;
  1111. this.open = true;
  1112. this.title = "修改员工";
  1113. this.form.password = "";
  1114. });
  1115. },
  1116. /** 重置密码按钮操作 */
  1117. handleResetPwd(row) {
  1118. this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
  1119. confirmButtonText: "确定",
  1120. cancelButtonText: "取消",
  1121. inputPlaceholder: "8-20 位,包含字母、数字和特殊字符",
  1122. inputValidator: (value) => {
  1123. const pattern = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,20}/;
  1124. const hasChinese = /[\u4e00-\u9fa5]/.test(value);
  1125. const hasFullWidth = /[!-~]/.test(value);
  1126. if (hasChinese) return '不能包含中文字符';
  1127. if (hasFullWidth) return '不能包含全角符号,请使用英文输入法';
  1128. if (!pattern.test(value)) return '密码格式错误:需包含字母、数字和英文特殊字符,长度为 8-20 位';
  1129. return true;
  1130. }
  1131. })
  1132. .then(({ value }) => {
  1133. resetUserPwd(row.userId, value).then((response) => {
  1134. if (response.code === 200) {
  1135. this.msgSuccess("修改成功,新密码是:" + value);
  1136. }
  1137. });
  1138. })
  1139. .catch(() => {
  1140. });
  1141. },
  1142. /** 提交按钮 */
  1143. submitForm: function() {
  1144. // this.onDomainBlur();
  1145. // const domainPattern = /^http:\/\/([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
  1146. // if (this.form.domain!=null && !domainPattern.test(this.form.domain)) {
  1147. // this.$message.error('请输入正确格式的域名,如:http://xxx.xxx.com');
  1148. // return;
  1149. // }
  1150. this.$refs["form"].validate((valid) => {
  1151. if (valid) {
  1152. if (this.form.userId != undefined) {
  1153. updateUser(this.form).then((response) => {
  1154. if (response.code === 200) {
  1155. this.msgSuccess("修改成功");
  1156. this.open = false;
  1157. this.getList();
  1158. }
  1159. });
  1160. } else {
  1161. addUser(this.form).then((response) => {
  1162. if (response.code === 200) {
  1163. this.msgSuccess("新增成功");
  1164. this.open = false;
  1165. this.getList();
  1166. }
  1167. });
  1168. }
  1169. }
  1170. });
  1171. },
  1172. downloadImage(imageSrc, fileName) {
  1173. const link = document.createElement('a');
  1174. link.href = imageSrc;
  1175. link.download = fileName || '绑定或新增销售.png';
  1176. document.body.appendChild(link);
  1177. link.click();
  1178. document.body.removeChild(link);
  1179. },
  1180. submitBingCompanyForm: function() {
  1181. this.$refs["formBindCompany"].validate((valid) => {
  1182. if (valid) {
  1183. let loadingRock = this.$loading({
  1184. lock: true,
  1185. text: '生成二维码中~~请不要刷新页面!!',
  1186. spinner: 'el-icon-loading',
  1187. background: 'rgba(0, 0, 0, 0.7)'
  1188. });
  1189. addCodeUrl(this.formBindCompany).then((response) => {
  1190. this.bindCompanyOpen = false;
  1191. this.bindCompanyUrl.url = response.data.url
  1192. this.bindCompanyUrl.open = true;
  1193. this.bindCompanyUrl.name = "绑定或新增 销售二维码";
  1194. }).finally(res => {
  1195. loadingRock.close();
  1196. })
  1197. }
  1198. });
  1199. },
  1200. /**
  1201. * 同步企业微信员工
  1202. */
  1203. synSubmitForm() {
  1204. this.synOpen = false;
  1205. this.loading = true;
  1206. /*this.msgSuccess("");
  1207. let loadingRock = this.$loading({
  1208. lock: true,
  1209. text: '同步中.....请等待.....请不要重复点击!!',
  1210. spinner: 'el-icon-loading',
  1211. background: 'rgba(0, 0, 0, 0.7)'
  1212. });*/
  1213. addQwUser(this.synform.corpId).then(response => {
  1214. //this.msgSuccess("同步成功");
  1215. this.msgSuccess("正在同步中...");
  1216. this.getList();
  1217. this.synOpen = false;
  1218. }).finally(() => {
  1219. this.loading = false;
  1220. this.synOpen = false;
  1221. //loadingRock.close();
  1222. });
  1223. },
  1224. synNameSubmitForm() {
  1225. this.synNameOpen = false;
  1226. this.loading = true;
  1227. addQwUserName(this.synNameform.corpId).then(response => {
  1228. // this.msgSuccess("同步成功");
  1229. this.msgSuccess("正在同步中...");
  1230. this.getList();
  1231. this.synNameOpen = false;
  1232. }).finally(() => {
  1233. this.loading = false;
  1234. this.synNameOpen = false;
  1235. //loadingRock.close();
  1236. });
  1237. },
  1238. /**
  1239. * 同步企业微信部门
  1240. */
  1241. qwSyncDept() {
  1242. syncDept().then(response => {
  1243. this.msgSuccess("同步成功");
  1244. this.getList();
  1245. }).catch(() => {
  1246. this.msgError("同步失败:" + response.msg);
  1247. })
  1248. },
  1249. qwSubmitForm() {
  1250. let loadingRock = this.$loading({
  1251. lock: true,
  1252. text: '绑定中.....同步客户信息中.....',
  1253. spinner: 'el-icon-loading',
  1254. background: 'rgba(0, 0, 0, 0.7)'
  1255. });
  1256. this.qwForm.id = (this.qwUser).join(',');
  1257. bindQwUser(this.qwForm).then(response => {
  1258. this.msgSuccess("绑定成功");
  1259. this.qwOpen = false;
  1260. this.getList();
  1261. this.qwUserId = null;
  1262. this.qwUser = [];
  1263. }).finally(res => {
  1264. loadingRock.close()
  1265. });
  1266. },
  1267. /** 删除按钮操作 */
  1268. handleDelete(row) {
  1269. const userIds = row.userId || this.ids;
  1270. this.$confirm(
  1271. '是否确认删除员工编号为"' + userIds + '"的数据项?【注意:删除后绑定的企业微信相关信息可能会错乱!!】',
  1272. "警告",
  1273. {
  1274. confirmButtonText: "确定",
  1275. cancelButtonText: "取消",
  1276. type: "warning",
  1277. }
  1278. )
  1279. .then(function() {
  1280. return delUser(userIds);
  1281. })
  1282. .then(() => {
  1283. this.getList();
  1284. this.msgSuccess("删除成功");
  1285. })
  1286. .catch(function() {
  1287. });
  1288. },
  1289. /** 导出按钮操作 */
  1290. handleExport() {
  1291. const queryParams = this.queryParams;
  1292. this.$confirm("是否确认导出所有用户数据项?", "警告", {
  1293. confirmButtonText: "确定",
  1294. cancelButtonText: "取消",
  1295. type: "warning",
  1296. })
  1297. .then(function() {
  1298. return exportUser(queryParams);
  1299. })
  1300. .then((response) => {
  1301. this.download(response.msg);
  1302. })
  1303. .catch(function() {
  1304. });
  1305. },
  1306. /** 导入按钮操作 */
  1307. handleImport() {
  1308. this.upload.title = "用户导入";
  1309. this.upload.open = true;
  1310. },
  1311. /** 下载模板操作 */
  1312. importTemplate() {
  1313. importTemplate().then((response) => {
  1314. this.download(response.msg);
  1315. });
  1316. },
  1317. // 文件上传中处理
  1318. handleFileUploadProgress(event, file, fileList) {
  1319. this.upload.isUploading = true;
  1320. },
  1321. // 文件上传成功处理
  1322. handleFileSuccess(response, file, fileList) {
  1323. this.upload.open = false;
  1324. this.upload.isUploading = false;
  1325. this.$refs.upload.clearFiles();
  1326. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  1327. this.getList();
  1328. },
  1329. // 提交上传文件
  1330. submitFileForm() {
  1331. this.$refs.upload.submit();
  1332. },
  1333. generateDomain() {
  1334. let queryParams;
  1335. if (this.form.userId) {
  1336. queryParams = {
  1337. 'userId': this.form.userId,
  1338. }
  1339. }
  1340. generateSubDomain(queryParams).then(response => {
  1341. this.form.domain = response.data
  1342. });
  1343. },
  1344. /** 设置单独注册会员按钮操作 */
  1345. handleSetRegister() {
  1346. this.registerOpen = true;
  1347. this.registerForm.status = false;
  1348. },
  1349. /** 提交设置单独注册会员 */
  1350. submitRegisterForm() {
  1351. setIsRegisterMember({ status: this.registerForm.status }, this.ids).then(response => {
  1352. if (response.code === 200) {
  1353. this.msgSuccess("设置成功");
  1354. this.registerOpen = false;
  1355. this.getList();
  1356. }
  1357. });
  1358. },
  1359. /** 开关是否允许所有方式注册会员 */
  1360. handleAllowedAllRegister() {
  1361. this.allowedAllRegisterOpen = true;
  1362. // this.allowedAllRegisterForm.status = true;
  1363. },
  1364. // 提交
  1365. submitAllowedAllRegisterForm() {
  1366. isAllowedAllRegister({ status: this.allowedAllRegisterForm.status }, this.ids).then(response => {
  1367. if (response.code === 200) {
  1368. this.msgSuccess("操作成功");
  1369. this.allowedAllRegisterOpen = false;
  1370. this.getList();
  1371. }
  1372. });
  1373. },
  1374. /**
  1375. * 上传文件之前的钩子,参数为上传的文件,若返回 false 或者返回 Promise且被 reject,则停止上传。
  1376. * @param {File} file - 用户选择的文件对象
  1377. * @param {Object} row - 当前行的数据对象
  1378. */
  1379. beforeImageUpload(file, row) {
  1380. // 清除之前的错误信息
  1381. this.$set(row, 'uploadError', '');
  1382. const isJPG = file.type === 'image/jpeg';
  1383. const isPNG = file.type === 'image/png';
  1384. const isGIF = file.type === 'image/gif'; // 根据需要添加更多格式
  1385. const isValidFormat = isJPG || isPNG || isGIF;
  1386. const isLt2M = file.size / 1024 / 1024 < 2; // 限制图片大小为 2MB
  1387. if (!isValidFormat) {
  1388. const errorMsg = '上传二维码图片只能是 JPG/PNG/GIF 格式!';
  1389. this.$message.error(errorMsg);
  1390. this.$set(row, 'uploadError', errorMsg); // 在行内显示错误
  1391. return false;
  1392. }
  1393. if (!isLt2M) {
  1394. const errorMsg = '上传二维码图片大小不能超过 2MB!';
  1395. this.$message.error(errorMsg);
  1396. this.$set(row, 'uploadError', errorMsg); // 在行内显示错误
  1397. return false;
  1398. }
  1399. return true; // 校验通过,允许上传
  1400. },
  1401. /**
  1402. * 自定义上传方法
  1403. * @param {Object} options - Element UI upload 组件传递的参数,包含 file, onSuccess, onError, onProgress 等
  1404. * @param {Object} row - 当前行的数据对象
  1405. */
  1406. async handleCustomUpload(options, row) {
  1407. const file = options.file;
  1408. const formData = new FormData();
  1409. formData.append('file', file);
  1410. formData.append('userId', row.userId)
  1411. this.$set(row, 'uploading', true);
  1412. this.$set(row, 'uploadError', '');
  1413. try {
  1414. const response = await axios.post(this.uploadUrl, formData, {
  1415. headers: {
  1416. 'Content-Type': 'multipart/form-data',
  1417. },
  1418. onUploadProgress: progressEvent => {
  1419. const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
  1420. console.log(`上传进度: ${percentCompleted}%`);
  1421. }
  1422. });
  1423. if (response.data && (response.data.url || (response.data.data && response.data.data.url))) {
  1424. const imageUrl = response.data.url || response.data.data.url;
  1425. this.$set(row, 'qrCodeWeixin', imageUrl); // 更新行数据中的图片URL
  1426. this.$message.success('图片上传成功!');
  1427. options.onSuccess(response.data, file); // 通知el-upload上传成功 (虽然我们自定义了,但调用一下也无妨)
  1428. } else {
  1429. const errorMsg = response.data.message || '图片上传失败,服务器未返回有效URL';
  1430. this.$message.error(errorMsg);
  1431. this.$set(row, 'uploadError', errorMsg);
  1432. options.onError(new Error(errorMsg), file); // 通知el-upload上传失败
  1433. }
  1434. } catch (error) {
  1435. console.error('上传失败:', error);
  1436. let errorMsg = '图片上传失败';
  1437. if (error.response && error.response.data && error.response.data.message) {
  1438. errorMsg = error.response.data.message;
  1439. } else if (error.message) {
  1440. errorMsg = error.message;
  1441. }
  1442. this.$message.error(errorMsg);
  1443. this.$set(row, 'uploadError', errorMsg);
  1444. options.onError(error, file); // 通知el-upload上传失败
  1445. } finally {
  1446. this.$set(row, 'uploading', false); // 无论成功失败,结束上传状态
  1447. }
  1448. },
  1449. requestUpload() {
  1450. },
  1451. beforeUpload() {
  1452. console.log(file.type)
  1453. const isPic =
  1454. file.type === 'image/jpeg' ||
  1455. file.type === 'image/png' ||
  1456. file.type === 'image/gif' ||
  1457. file.type === 'image/jpg' ||
  1458. file.type === 'audio/mpeg'
  1459. const isLt2M = file.size / 1024 / 1024 < 2
  1460. if (!isPic) {
  1461. this.$message.error('上传图片只能是 JPG、JPEG、PNG、GIF 格式!')
  1462. return false
  1463. }
  1464. if (!isLt2M) {
  1465. this.$message.error('上传头像图片大小不能超过 2MB!')
  1466. }
  1467. return isPic && isLt2M
  1468. },
  1469. handleUpdateDoctor(row) {
  1470. this.doctor.title = "绑定医生"
  1471. this.doctor.open = true;
  1472. this.doctorForm.userId = row.userId;
  1473. },
  1474. bindCompanyUserDoctorId(row) {
  1475. console.log(row)
  1476. this.doctorForm.doctorId = row;
  1477. bindDoctorId(this.doctorForm).then(res => {
  1478. if (res.code == 200) {
  1479. this.$message.success('绑定成功')
  1480. } else {
  1481. this.$message.error('绑定失败:', res.msg)
  1482. }
  1483. this.getList()
  1484. this.doctor.open = false;
  1485. })
  1486. },
  1487. handleUnBindUserId(val) {
  1488. this.$confirm(
  1489. '确认解绑医生:<span style="color: green;">' + val.nickName + '' +
  1490. '</span> 的医生?',
  1491. {
  1492. confirmButtonText: "确定",
  1493. cancelButtonText: "取消",
  1494. type: "warning",
  1495. dangerouslyUseHTMLString: true // 允许使用 HTML 字符串
  1496. }
  1497. ).then(() => {
  1498. return unBindDoctorId(val.userId);
  1499. }).then(response => {
  1500. this.getList();
  1501. this.msgSuccess("解绑成功");
  1502. }).finally(res => {
  1503. this.getList();
  1504. })
  1505. },
  1506. },
  1507. }
  1508. </script>