index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  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. getCompanyList().then(response => {
  471. this.companys = response.data;
  472. });
  473. },
  474. methods: {
  475. handleCompanyQuery() {
  476. this.queryCompanyParams.pageNum = 1;
  477. },
  478. resetCompanyQuery() {
  479. this.resetForm("queryCompanyForm");
  480. this.handleCompanyQuery();
  481. },
  482. /** 查询企业列表 */
  483. getCompanyList() {
  484. this.companysloading = true;
  485. listCompany(this.queryCompanyParams).then(response => {
  486. this.companyList = response.rows;
  487. this.companyTotal = response.total;
  488. this.companysloading = false;
  489. });
  490. },
  491. /** 查询sop模板列表 */
  492. getList() {
  493. this.loading = true;
  494. listSopTemp(this.queryParams).then(response => {
  495. this.sopTempList = response.rows;
  496. this.total = response.total;
  497. this.loading = false;
  498. });
  499. },
  500. // 取消按钮
  501. cancel() {
  502. this.open = false;
  503. this.reset();
  504. },
  505. // 表单重置
  506. reset() {
  507. this.form = {
  508. gap: 1,
  509. sendType: this.sendType,
  510. sort: 0,
  511. time: "",
  512. num: 1,
  513. timeList: [{value: ""}],
  514. status: "1",
  515. };
  516. this.resetForm("form");
  517. },
  518. /** 搜索按钮操作 */
  519. handleQuery() {
  520. this.queryParams.pageNum = 1;
  521. this.getList();
  522. },
  523. /** 重置按钮操作 */
  524. resetQuery() {
  525. this.resetForm("queryForm");
  526. this.handleQuery();
  527. },
  528. handleCommand(command) {
  529. // if (command==4) {
  530. // this.$router.push('/qw/sopTemp/addAiChatTemp')
  531. // }else{
  532. this.sendType = command;
  533. this.title = "新增";
  534. this.reset();
  535. this.open = true;
  536. // this.$router.push('/qw/sopTemp/addTemp/'+command)
  537. // }
  538. },
  539. // 多选框选中数据
  540. handleSelectionChange(selection) {
  541. this.ids = selection.map(item => item.id)
  542. this.single = selection.length !== 1
  543. this.multiple = !selection.length
  544. },
  545. //销售公司多选
  546. handleSelectionCompany(selection) {
  547. this.companys = selection.map(item => item.companyId)
  548. this.single = selection.length !== 1
  549. this.multiple = !selection.length
  550. },
  551. /** 新增按钮操作 */
  552. // handleAdd() {
  553. // this.$router.push('/qw/sopTemp/addSopTemp')
  554. // },
  555. /**
  556. * 查看详情
  557. */
  558. handleQueryDetails(row) {
  559. // if (row.sendType==4) {
  560. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/3`)
  561. // }else{
  562. this.$router.push(`/qw/sopTemp/updateSopTemp/${row.id}/3`)
  563. // }
  564. },
  565. /** 修改按钮操作 */
  566. handleUpdate(row) {
  567. // if (row.sendType==4) {
  568. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/1`)
  569. // }else{
  570. this.getInfo(row.id, 1);
  571. // this.$router.push(`/qw/sopTemp/updateTemp/${row.id}/1`)
  572. // }
  573. },
  574. /** 修改按钮操作 */
  575. handleUpdate2(row) {
  576. // if (row.sendType==4) {
  577. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/1`)
  578. // }else{
  579. let url = `/qw/sopTemp/updateSopTemp/${row.id}/1`;
  580. console.info(url)
  581. this.$router.push(url)
  582. // }
  583. },
  584. /** 修改按钮操作 */
  585. handleUpdateRed(row) {
  586. this.redData.open = true;
  587. redList(row.id).then(e => {
  588. this.redData.loading = false;
  589. this.redData.list = e.data;
  590. })
  591. },
  592. /** 修改按钮操作 */
  593. updateRedData() {
  594. this.redData.loading = true;
  595. updateRedPackage({list: this.redData.list}).then(e => {
  596. this.redData.open = false;
  597. this.getList();
  598. }).catch(() => {
  599. this.redData.loading = false;
  600. });
  601. },
  602. /** 分享模板 */
  603. shareTemplate(row) {
  604. this.shareOptions.open = true;
  605. this.shareOptions.templateId = row.id;
  606. },
  607. /**
  608. * 复制模板
  609. */
  610. copyTemplate(row) {
  611. // if(row.sendType==4){
  612. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/2`)
  613. // }else{
  614. this.getInfo(row.id, 2);
  615. // this.$router.push(`/qw/sopTemp/updateSopTemp/${row.id}/2`)
  616. // }
  617. },
  618. getInfo(id, command) {
  619. getSopTemp(id).then(response => {
  620. this.command = command;
  621. if (command == 2) {
  622. this.title = "复制";
  623. }
  624. if (command == 1) {
  625. this.title = "修改";
  626. }
  627. this.form = response.data;
  628. this.open = true;
  629. });
  630. },
  631. /** 提交按钮 */
  632. submitForm() {
  633. delete this.form.rules
  634. this.$refs["form"].validate(valid => {
  635. if (valid) {
  636. let f = JSON.parse(JSON.stringify(this.form));
  637. if (f.timeList && f.timeList.length > 0) {
  638. f.timeList = f.timeList.map(item => item.value);
  639. }
  640. const loading = this.$loading({
  641. lock: true,
  642. text: 'Loading',
  643. spinner: 'el-icon-loading',
  644. background: 'rgba(0, 0, 0, 0.7)'
  645. });
  646. if (this.command == 2) {
  647. copyTemplate(f).then(response => {
  648. this.msgSuccess("复制成功");
  649. this.open = false;
  650. loading.close();
  651. this.getList();
  652. });
  653. } else {
  654. if (f.id != null) {
  655. updateTemp(f).then(response => {
  656. this.msgSuccess("修改成功");
  657. this.open = false;
  658. loading.close();
  659. this.getList();
  660. });
  661. } else {
  662. addTemp(f).then(response => {
  663. this.msgSuccess("新增成功");
  664. this.open = false;
  665. loading.close();
  666. this.getList();
  667. });
  668. }
  669. }
  670. }
  671. });
  672. },
  673. handleShareTemplate() {
  674. const companyIds = this.companys;
  675. let templateId = this.shareOptions.templateId;
  676. this.$confirm("确定将模板分享给 公司编号为:" + companyIds + "的公司?", "提醒", {
  677. confirmButtonText: "确定",
  678. cancelButtonText: "取消",
  679. type: "warning"
  680. }).then(function () {
  681. return shareSopTemp({companyIds: companyIds, templeId: templateId});
  682. }).then(() => {
  683. this.companys = [];
  684. this.shareOptions.open = false;
  685. this.getList();
  686. this.msgSuccess("分享成功");
  687. });
  688. },
  689. /** 删除按钮操作 */
  690. handleDelete(row) {
  691. const ids = row.id || this.ids;
  692. this.$confirm('是否确认删除sop模板编号为"' + ids + '"的数据项?', "警告", {
  693. confirmButtonText: "确定",
  694. cancelButtonText: "取消",
  695. type: "warning"
  696. }).then(function () {
  697. return delSopTemp(ids);
  698. }).then(() => {
  699. this.getList();
  700. this.msgSuccess("删除成功");
  701. }).catch(() => {
  702. });
  703. },
  704. /** 导出按钮操作 */
  705. handleExport() {
  706. const queryParams = this.queryParams;
  707. this.$confirm('是否确认导出所有sop模板数据项?', "警告", {
  708. confirmButtonText: "确定",
  709. cancelButtonText: "取消",
  710. type: "warning"
  711. }).then(() => {
  712. this.exportLoading = true;
  713. return exportSopTemp(queryParams);
  714. }).then(response => {
  715. this.download(response.msg);
  716. this.exportLoading = false;
  717. }).catch(() => {
  718. });
  719. },
  720. sendNumChange(val, old) {
  721. if (val > old) {
  722. for (let i = 0; i < val - old; i++) {
  723. this.form.timeList.push({value: ""});
  724. }
  725. } else {
  726. let len = old - val;
  727. this.form.timeList.splice(Math.max(this.form.timeList.length - len, 0), len);
  728. }
  729. }
  730. }
  731. };
  732. </script>