index.vue 53 KB

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