index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="模板标题" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入模板标题"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="状态" prop="status">
  14. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  15. <el-option
  16. v-for="dict in statusOptions"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="模板类型" prop="sendType">
  24. <el-select v-model="queryParams.sendType" placeholder="请选择类型" clearable size="small">
  25. <el-option
  26. v-for="dict in sysQwSopType"
  27. :key="dict.dictValue"
  28. :label="dict.dictLabel"
  29. :value="dict.dictValue"
  30. />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="排序" prop="sort">
  34. <el-input
  35. v-model="queryParams.sort"
  36. placeholder="请输入排序"
  37. clearable
  38. size="small"
  39. @keyup.enter.native="handleQuery"
  40. />
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  44. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  45. </el-form-item>
  46. </el-form>
  47. <el-row :gutter="10" class="mb8">
  48. <el-col :span="1.5">
  49. <!-- <el-button-->
  50. <!-- type="primary"-->
  51. <!-- plain-->
  52. <!-- icon="el-icon-plus"-->
  53. <!-- size="mini"-->
  54. <!-- @click="handleAdd"-->
  55. <!-- v-hasPermi="['qw:sopTemp:add']"-->
  56. <!-- >新增</el-button>-->
  57. <el-dropdown
  58. v-if="roles.includes('add_sop_temp')"
  59. @command="handleCommand"
  60. trigger="click"
  61. placement="bottom-start"
  62. >
  63. <el-dropdown-menu slot="dropdown" style="width: 120px;">
  64. <el-dropdown-item
  65. v-for="option in sysQwSopType"
  66. :key="option.dictValue"
  67. :command="option.dictValue"
  68. >
  69. <i :class="option.iconClass" style="margin-right: 10px;"></i>
  70. {{ option.dictLabel }}
  71. </el-dropdown-item>
  72. </el-dropdown-menu>
  73. <span class="el-dropdown-link">
  74. <el-button type="primary" icon="el-icon-plus" plain size="mini">
  75. 新增模板
  76. </el-button>
  77. </span>
  78. </el-dropdown>
  79. </el-col>
  80. <el-col :span="1.5">
  81. <el-button
  82. type="danger"
  83. plain
  84. icon="el-icon-delete"
  85. size="mini"
  86. :disabled="multiple"
  87. @click="handleDelete"
  88. v-if="roles.includes('del_sop_temp')"
  89. v-hasPermi="['qw:sopTemp:remove']"
  90. >删除
  91. </el-button>
  92. </el-col>
  93. <el-col :span="1.5">
  94. <el-button
  95. type="warning"
  96. plain
  97. icon="el-icon-download"
  98. size="mini"
  99. :loading="exportLoading"
  100. @click="handleExport"
  101. v-hasPermi="['qw:sopTemp:export']"
  102. >导出
  103. </el-button>
  104. </el-col>
  105. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  106. </el-row>
  107. <el-table v-loading="loading" border :data="sopTempList" @selection-change="handleSelectionChange">
  108. <el-table-column type="selection" width="55" align="center"/>
  109. <el-table-column label="模板编号" align="center" prop="id"/>
  110. <el-table-column label="模板编号" align="center">
  111. <template slot-scope="scope">
  112. <el-tag v-for="item in companys" v-if="scope.row.companyId == item.companyId">{{item.companyName}}</el-tag>
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="模板标题" align="center" prop="name"/>
  116. <el-table-column label="模板类型" align="center" prop="sendType">
  117. <template slot-scope="scope">
  118. <dict-tag :options="sysQwSopType" :value="scope.row.sendType"/>
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="间隔天数" align="center" prop="gap"/>
  122. <el-table-column label="状态" align="center" prop="status">
  123. <template slot-scope="scope">
  124. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="创建时间" align="center" prop="createTime"/>
  128. <el-table-column label="修改时间" align="center" prop="updateTime"/>
  129. <el-table-column label="排序" align="center" prop="sort"/>
  130. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  131. <template slot-scope="scope">
  132. <el-button
  133. size="mini"
  134. type="text"
  135. icon="el-icon-connection"
  136. v-if="roles.includes('update_sop_temp')"
  137. @click="copyTemplate(scope.row)"
  138. v-hasPermi="['qw:sopTemp:edit']"
  139. >复制模板
  140. </el-button>
  141. <el-button
  142. size="mini"
  143. type="text"
  144. icon="el-icon-share"
  145. @click="shareTemplate(scope.row)"
  146. v-hasPermi="['qw:sopTemp:share']"
  147. >分享模板</el-button>
  148. <el-button
  149. size="mini"
  150. type="text"
  151. icon="el-icon-s-promotion"
  152. @click="handleQueryDetails(scope.row)"
  153. v-hasPermi="['qw:sopTemp:list']"
  154. >详情
  155. </el-button>
  156. <el-button
  157. size="mini"
  158. type="text"
  159. icon="el-icon-edit"
  160. v-if="roles.includes('update_sop_temp')"
  161. @click="handleUpdate(scope.row)"
  162. v-hasPermi="['qw:sopTemp:edit']"
  163. >修改
  164. </el-button>
  165. <el-button
  166. size="mini"
  167. type="text"
  168. icon="el-icon-edit"
  169. @click="handleUpdate2(scope.row)"
  170. v-if="roles.includes('update_sop_temp')"
  171. v-hasPermi="['qw:sopTemp:edit']"
  172. >管理规则
  173. </el-button>
  174. <el-button
  175. size="mini"
  176. type="text"
  177. icon="el-icon-edit"
  178. @click="handleUpdateRed(scope.row)"
  179. v-if="scope.row.sendType == 5 && roles.includes('update_sop_temp_red')"
  180. v-hasPermi="['qw:sopTemp:edit']"
  181. >红包设置
  182. </el-button>
  183. <el-button
  184. size="mini"
  185. type="text"
  186. icon="el-icon-delete"
  187. @click="handleDelete(scope.row)"
  188. v-if="roles.includes('del_sop_temp')"
  189. v-hasPermi="['qw:sopTemp:remove']"
  190. >删除
  191. </el-button>
  192. </template>
  193. </el-table-column>
  194. </el-table>
  195. <pagination
  196. v-show="total>0"
  197. :total="total"
  198. :page.sync="queryParams.pageNum"
  199. :limit.sync="queryParams.pageSize"
  200. @pagination="getList"
  201. />
  202. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  203. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  204. <el-form-item label="名称" prop="name">
  205. <el-input v-model="form.name" placeholder="请输入模板标题"/>
  206. </el-form-item>
  207. <el-form-item label="状态">
  208. <el-radio-group v-model="form.status">
  209. <el-radio
  210. v-for="dict in statusOptions"
  211. :key="dict.dictValue"
  212. :label="dict.dictValue"
  213. >{{ dict.dictLabel }}
  214. </el-radio>
  215. </el-radio-group>
  216. </el-form-item>
  217. <el-form-item label="所属项目" prop="project" v-if="form.sendType != 5">
  218. <el-select v-model="form.project" placeholder="请选择项目" filterable clearable size="small">
  219. <el-option
  220. v-for="dict in projectOptions"
  221. :key="dict.dictValue"
  222. :label="dict.dictLabel"
  223. :value="dict.dictValue"
  224. />
  225. </el-select>
  226. </el-form-item>
  227. <el-form-item label="课程" prop="courseId" v-if="form.sendType == 11 && !form.id">
  228. <el-select v-model="form.courseId"placeholder="请选择课程" style=" margin-right: 10px;" size="mini" filterable>
  229. <el-option
  230. v-for="dict in courseList"
  231. :key="dict.dictValue"
  232. :label="dict.dictLabel"
  233. :value="parseInt(dict.dictValue)"
  234. />
  235. </el-select>
  236. </el-form-item>
  237. <el-form-item label="间隔天数" prop="gap">
  238. <el-input-number v-model="form.gap" :min="1" label="间隔天数"></el-input-number>
  239. </el-form-item>
  240. <el-form-item label="排序" prop="sort">
  241. <el-input-number v-model="form.sort" :min="0" label="排序"></el-input-number>
  242. </el-form-item>
  243. <el-form-item label="发课时间" prop="time" v-if="form.sendType == 11 && !form.id">
  244. <el-time-picker
  245. class="custom-input"
  246. v-model="form.time"
  247. value-format="HH:mm"
  248. format="HH:mm"
  249. placeholder="时间"
  250. style="width: 100px;height: 20px;margin-left: 10px;margin-top: 10px">
  251. </el-time-picker>
  252. </el-form-item>
  253. <el-form-item label="每天催课次数" prop="num" v-if="form.sendType == 11 && !form.id">
  254. <el-input-number v-model="form.num" :min="1" label="每天催课次数" @change="sendNumChange"></el-input-number>
  255. </el-form-item>
  256. <el-form-item label="催课时间" v-if="form.sendType == 11 && !form.id">
  257. <el-time-picker
  258. v-for="item in form.timeList"
  259. class="custom-input"
  260. v-model="item.value"
  261. value-format="HH:mm"
  262. format="HH:mm"
  263. :picker-options="{ selectableRange: startTimeRange }"
  264. placeholder="时间"
  265. style="width: 100px;height: 20px;margin-left: 10px;margin-top: 10px">
  266. </el-time-picker>
  267. </el-form-item>
  268. </el-form>
  269. <div slot="footer" class="dialog-footer" style="display: flex;justify-content: flex-end;">
  270. <el-button type="primary" @click="submitForm">确 定</el-button>
  271. <el-button @click="cancel">取 消</el-button>
  272. </div>
  273. </el-dialog>
  274. <el-dialog title="课程红包" :visible.sync="redData.open" width="900px" append-to-body>
  275. <el-table v-loading="redData.loading" border :data="redData.list" height="500px">
  276. <el-table-column label="小节" align="left" prop="videoName"/>
  277. <el-table-column label="金额" align="center">
  278. <template slot-scope="scope">
  279. <el-input-number v-model="scope.row.redPacketMoney" :min="0.01" step="0.01" label="红包金额"></el-input-number>
  280. </template>
  281. </el-table-column>
  282. </el-table>
  283. <div slot="footer" class="dialog-footer" style="display: flex;justify-content: flex-end;">
  284. <el-button type="primary" @click="updateRedData" :disabled="redData.loading">保 存</el-button>
  285. </div>
  286. </el-dialog>
  287. <el-dialog :title="shareOptions.title" :visible.sync="shareOptions.open" width="800px" append-to-body>
  288. <el-form :model="queryCompanyParams" ref="queryCompanyForm" :inline="true" v-show="showSearch" label-width="68px">
  289. <el-form-item label="公司名称" prop="companyName">
  290. <el-input
  291. style="width: 220px"
  292. v-model="queryCompanyParams.companyName"
  293. placeholder="请输入企业名称"
  294. clearable
  295. size="small"
  296. @keyup.enter.native="handleCompanyQuery"
  297. />
  298. </el-form-item>
  299. <el-form-item label="状态" prop="status">
  300. <el-select style="width: 220px" v-model="queryCompanyParams.status" placeholder="请选择状态" clearable size="small">
  301. <el-option
  302. v-for="dict in statusOptions"
  303. :key="dict.dictValue"
  304. :label="dict.dictLabel"
  305. :value="dict.dictValue"
  306. />
  307. </el-select>
  308. </el-form-item>
  309. <el-form-item>
  310. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleCompanyQuery">搜索</el-button>
  311. <el-button icon="el-icon-refresh" size="mini" @click="resetCompanyQuery">重置</el-button>
  312. </el-form-item>
  313. </el-form>
  314. <el-row :gutter="10" class="mb8">
  315. <el-col :span="1.5">
  316. <el-button
  317. plain
  318. type="primary"
  319. icon="el-icon-connection"
  320. size="mini"
  321. :disabled="multiple"
  322. @click="handleShareTemplate"
  323. v-hasPermi="['qw:sopTemp:share']"
  324. >分享模板</el-button>
  325. </el-col>
  326. </el-row>
  327. <el-table v-loading="companysloading" border :data="companyList" @selection-change="handleSelectionCompany">
  328. <el-table-column type="selection" width="55" align="center" />
  329. <el-table-column label="公司编号" align="center" prop="companyId" />
  330. <el-table-column label="企业名" align="center" prop="companyName" />
  331. <!-- <el-table-column label="备注" align="center" prop="remark"/>-->
  332. <el-table-column label="状态" align="center" prop="status" >
  333. <template slot-scope="scope">
  334. <el-tag prop="status" v-for="(item, index) in statusOptions" :type="scope.row.status==1?'success':'danger'" v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
  335. </template>
  336. </el-table-column>
  337. </el-table>
  338. <pagination
  339. v-show="companyTotal>0"
  340. :total="companyTotal"
  341. :page.sync="queryCompanyParams.pageNum"
  342. :limit.sync="queryCompanyParams.pageSize"
  343. @pagination="getCompanyList"
  344. />
  345. </el-dialog>
  346. </div>
  347. </template>
  348. <script>
  349. import {
  350. addTemp,
  351. copyTemplate,
  352. delSopTemp,
  353. exportSopTemp,
  354. getSopTemp,
  355. listSopTemp,
  356. getSelectableRange,
  357. redList,
  358. shareSopTemp,
  359. updateRedPackage,
  360. updateTemp
  361. } from "@/api/qw/sopTemp";
  362. import { getCompanyList, listCompany } from '@/api/company/company'
  363. import {courseList, getRoles} from "@/api/qw/sop";
  364. export default {
  365. name: "SopTemp",
  366. data() {
  367. return {
  368. // 遮罩层
  369. loading: true,
  370. companysloading: false,
  371. // 导出遮罩层
  372. exportLoading: false,
  373. // 选中数组
  374. ids: [],
  375. courseList: [],
  376. roles: [],
  377. //选中的公司
  378. companys: [],
  379. // 非单个禁用
  380. single: true,
  381. // 非多个禁用
  382. multiple: true,
  383. // 显示搜索条件
  384. showSearch: true,
  385. // 总条数
  386. companyTotal: 0,
  387. total: 0,
  388. sendType: 0,
  389. // sop模板表格数据
  390. sopTempList: [],
  391. sysQwSopType: [],
  392. companyList: [],
  393. projectOptions: [],
  394. startTimeRange: [],
  395. // 弹出层标题
  396. title: "",
  397. // 是否显示弹出层
  398. open: false,
  399. command: 0,
  400. // 状态字典
  401. statusOptions: [],
  402. shareOptions: {
  403. title: '分享模板',
  404. open: false,
  405. templateId: null,
  406. },
  407. redData: {
  408. open: false,
  409. loading: true,
  410. list: [],
  411. },
  412. queryCompanyParams: {
  413. pageNum: 1,
  414. pageSize: 10,
  415. companyName: null,
  416. status: null,
  417. },
  418. // 查询参数
  419. queryParams: {
  420. pageNum: 1,
  421. pageSize: 10,
  422. name: null,
  423. setting: null,
  424. status: '1',
  425. sort: null,
  426. companyId: null
  427. },
  428. // 表单参数
  429. form: {},
  430. // 表单校验
  431. rules: {
  432. name: [
  433. {required: true, message: '名称不能为空', trigger: 'blur'}
  434. ],
  435. status: [
  436. {required: true, message: '状态不能为空', trigger: 'blur'}
  437. ],
  438. sort: [
  439. {required: true, message: '排序不能为空', trigger: 'blur'}
  440. ],
  441. gap: [
  442. {required: true, message: '间隔天数不能为空', trigger: 'blur'}
  443. ],
  444. },
  445. contentRules: {
  446. time: [{required: true, message: '时间不能为空', trigger: 'blur'}],
  447. }
  448. };
  449. },
  450. created() {
  451. this.getList();
  452. getRoles().then(res => {
  453. this.roles = res.data;
  454. })
  455. this.getDicts("sys_company_status").then(response => {
  456. this.statusOptions = response.data;
  457. });
  458. getSelectableRange().then(e => {
  459. this.startTimeRange = e.data;
  460. })
  461. this.getDicts("sys_course_project").then(response => {
  462. this.projectOptions = response.data;
  463. });
  464. this.getDicts("sys_qw_sop_type").then(response => {
  465. this.sysQwSopType = response.data;
  466. });
  467. courseList().then(response => {
  468. this.courseList = response.list;
  469. });
  470. this.getCompanyList();
  471. getCompanyList().then(response => {
  472. this.companys = response.data;
  473. });
  474. },
  475. methods: {
  476. handleCompanyQuery() {
  477. this.queryCompanyParams.pageNum = 1;
  478. },
  479. resetCompanyQuery() {
  480. this.resetForm("queryCompanyForm");
  481. this.handleCompanyQuery();
  482. },
  483. /** 查询企业列表 */
  484. getCompanyList() {
  485. this.companysloading = true;
  486. listCompany(this.queryCompanyParams).then(response => {
  487. this.companyList = response.rows;
  488. this.companyTotal = response.total;
  489. this.companysloading = false;
  490. });
  491. },
  492. /** 查询sop模板列表 */
  493. getList() {
  494. this.loading = true;
  495. listSopTemp(this.queryParams).then(response => {
  496. this.sopTempList = response.rows;
  497. this.total = response.total;
  498. this.loading = false;
  499. });
  500. },
  501. // 取消按钮
  502. cancel() {
  503. this.open = false;
  504. this.reset();
  505. },
  506. // 表单重置
  507. reset() {
  508. this.form = {
  509. gap: 1,
  510. sendType: this.sendType,
  511. sort: 0,
  512. time: "",
  513. num: 1,
  514. timeList: [{value: ""}],
  515. status: "1",
  516. };
  517. this.resetForm("form");
  518. },
  519. /** 搜索按钮操作 */
  520. handleQuery() {
  521. this.queryParams.pageNum = 1;
  522. this.getList();
  523. },
  524. /** 重置按钮操作 */
  525. resetQuery() {
  526. this.resetForm("queryForm");
  527. this.handleQuery();
  528. },
  529. handleCommand(command) {
  530. // if (command==4) {
  531. // this.$router.push('/qw/sopTemp/addAiChatTemp')
  532. // }else{
  533. this.sendType = command;
  534. this.title = "新增";
  535. this.reset();
  536. this.open = true;
  537. // this.$router.push('/qw/sopTemp/addTemp/'+command)
  538. // }
  539. },
  540. // 多选框选中数据
  541. handleSelectionChange(selection) {
  542. this.ids = selection.map(item => item.id)
  543. this.single = selection.length !== 1
  544. this.multiple = !selection.length
  545. },
  546. //销售公司多选
  547. handleSelectionCompany(selection) {
  548. this.companys = selection.map(item => item.companyId)
  549. this.single = selection.length !== 1
  550. this.multiple = !selection.length
  551. },
  552. /** 新增按钮操作 */
  553. // handleAdd() {
  554. // this.$router.push('/qw/sopTemp/addSopTemp')
  555. // },
  556. /**
  557. * 查看详情
  558. */
  559. handleQueryDetails(row) {
  560. // if (row.sendType==4) {
  561. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/3`)
  562. // }else{
  563. this.$router.push(`/qw/sopTemp/updateSopTemp/${row.id}/3`)
  564. // }
  565. },
  566. /** 修改按钮操作 */
  567. handleUpdate(row) {
  568. // if (row.sendType==4) {
  569. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/1`)
  570. // }else{
  571. this.getInfo(row.id, 1);
  572. // this.$router.push(`/qw/sopTemp/updateTemp/${row.id}/1`)
  573. // }
  574. },
  575. /** 修改按钮操作 */
  576. handleUpdate2(row) {
  577. // if (row.sendType==4) {
  578. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/1`)
  579. // }else{
  580. let url = `/qw/sopTemp/updateSopTemp/${row.id}/1`;
  581. console.info(url)
  582. this.$router.push(url)
  583. // }
  584. },
  585. /** 修改按钮操作 */
  586. handleUpdateRed(row) {
  587. this.redData.open = true;
  588. redList(row.id).then(e => {
  589. this.redData.loading = false;
  590. this.redData.list = e.data;
  591. })
  592. },
  593. /** 修改按钮操作 */
  594. updateRedData() {
  595. this.redData.loading = true;
  596. updateRedPackage({list: this.redData.list}).then(e => {
  597. this.redData.open = false;
  598. this.getList();
  599. }).catch(() => {
  600. this.redData.loading = false;
  601. });
  602. },
  603. /** 分享模板 */
  604. shareTemplate(row) {
  605. this.shareOptions.open = true;
  606. this.shareOptions.templateId = row.id;
  607. },
  608. /**
  609. * 复制模板
  610. */
  611. copyTemplate(row) {
  612. // if(row.sendType==4){
  613. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/2`)
  614. // }else{
  615. this.getInfo(row.id, 2);
  616. // this.$router.push(`/qw/sopTemp/updateSopTemp/${row.id}/2`)
  617. // }
  618. },
  619. getInfo(id, command) {
  620. getSopTemp(id).then(response => {
  621. this.command = command;
  622. if (command == 2) {
  623. this.title = "复制";
  624. }
  625. if (command == 1) {
  626. this.title = "修改";
  627. }
  628. this.form = response.data;
  629. this.open = true;
  630. });
  631. },
  632. /** 提交按钮 */
  633. submitForm() {
  634. delete this.form.rules
  635. this.$refs["form"].validate(valid => {
  636. if (valid) {
  637. let f = JSON.parse(JSON.stringify(this.form));
  638. if (f.timeList && f.timeList.length > 0) {
  639. f.timeList = f.timeList.map(item => item.value);
  640. }
  641. const loading = this.$loading({
  642. lock: true,
  643. text: 'Loading',
  644. spinner: 'el-icon-loading',
  645. background: 'rgba(0, 0, 0, 0.7)'
  646. });
  647. if (this.command == 2) {
  648. copyTemplate(f).then(response => {
  649. this.msgSuccess("复制成功");
  650. this.open = false;
  651. loading.close();
  652. this.getList();
  653. });
  654. } else {
  655. if (f.id != null) {
  656. updateTemp(f).then(response => {
  657. this.msgSuccess("修改成功");
  658. this.open = false;
  659. loading.close();
  660. this.getList();
  661. });
  662. } else {
  663. addTemp(f).then(response => {
  664. this.msgSuccess("新增成功");
  665. this.open = false;
  666. loading.close();
  667. this.getList();
  668. });
  669. }
  670. }
  671. }
  672. });
  673. },
  674. handleShareTemplate() {
  675. const companyIds = this.companys;
  676. let templateId = this.shareOptions.templateId;
  677. this.$confirm("确定将模板分享给 公司编号为:" + companyIds + "的公司?", "提醒", {
  678. confirmButtonText: "确定",
  679. cancelButtonText: "取消",
  680. type: "warning"
  681. }).then(function () {
  682. return shareSopTemp({companyIds: companyIds, templeId: templateId});
  683. }).then(() => {
  684. this.companys = [];
  685. this.shareOptions.open = false;
  686. this.getList();
  687. this.msgSuccess("分享成功");
  688. });
  689. },
  690. /** 删除按钮操作 */
  691. handleDelete(row) {
  692. const ids = row.id || this.ids;
  693. this.$confirm('是否确认删除sop模板编号为"' + ids + '"的数据项?', "警告", {
  694. confirmButtonText: "确定",
  695. cancelButtonText: "取消",
  696. type: "warning"
  697. }).then(function () {
  698. return delSopTemp(ids);
  699. }).then(() => {
  700. this.getList();
  701. this.msgSuccess("删除成功");
  702. }).catch(() => {
  703. });
  704. },
  705. /** 导出按钮操作 */
  706. handleExport() {
  707. const queryParams = this.queryParams;
  708. this.$confirm('是否确认导出所有sop模板数据项?', "警告", {
  709. confirmButtonText: "确定",
  710. cancelButtonText: "取消",
  711. type: "warning"
  712. }).then(() => {
  713. this.exportLoading = true;
  714. return exportSopTemp(queryParams);
  715. }).then(response => {
  716. this.download(response.msg);
  717. this.exportLoading = false;
  718. }).catch(() => {
  719. });
  720. },
  721. sendNumChange(val, old) {
  722. if (val > old) {
  723. for (let i = 0; i < val - old; i++) {
  724. this.form.timeList.push({value: ""});
  725. }
  726. } else {
  727. let len = old - val;
  728. this.form.timeList.splice(Math.max(this.form.timeList.length - len, 0), len);
  729. }
  730. }
  731. }
  732. };
  733. </script>