index.vue 53 KB

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