tzfs.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <template>
  2. <div class="app-container">
  3. <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px"
  4. label-position="left">
  5. <el-row>
  6. <el-col :span="24">
  7. <el-form-item label="收件主体" prop="deptflg" >
  8. <el-radio-group v-model="formData.deptflg" size="medium" @change="agreeChange">
  9. <el-radio v-for="(item, index) in deptflgOptions" :key="index" :label="item.value"
  10. :disabled="item.disabled">{{item.label}}</el-radio>
  11. </el-radio-group>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :span="24" v-if="showsjr">
  15. <el-form-item label="收件人" prop="RecvPerson">
  16. <el-input v-model="formData.RecvPerson" placeholder="请选择收件人" clearable="true":disabled="true">
  17. <template slot="append">
  18. <el-button
  19. type="primary"
  20. icon="el-icon-plus"
  21. size="mini"
  22. @click="handleSelect">
  23. 选择人员
  24. </el-button>
  25. </template>
  26. </el-input>
  27. <el-input v-model="formData.RecvAccount" v-show="false"/>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="24" v-if="showdw">
  31. <el-form-item label="收件单位" prop="deptId">
  32. <el-input v-model="formData.RecvPerson" placeholder="请选择单位" clearable="true":disabled="true">
  33. <template slot="append">
  34. <el-button
  35. type="primary"
  36. icon="el-icon-plus"
  37. size="mini"
  38. @click="handledept">
  39. 选择单位
  40. </el-button>
  41. </template>
  42. </el-input>
  43. <el-input v-model="formData.RecvAccount" v-show="false"/>
  44. </el-form-item>
  45. </el-col>
  46. <el-col :span="24">
  47. <el-form-item label="通知标题" prop="Title">
  48. <el-input v-model="formData.Title" placeholder="请输入通知标题" clearable :style="{width: '100%'}">
  49. </el-input>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="24">
  53. <el-form-item label="通知内容" prop="Content" style="height: 240px;">
  54. <Editor v-model="formData.Content" />
  55. <!-- <el-input v-model="formData.Content" type="textarea" placeholder="请输入通知内容"-->
  56. <!-- :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>-->
  57. </el-form-item>
  58. </el-col>
  59. <el-col :span="24">
  60. <el-form-item label="附件上传" prop="fj">
  61. <el-upload action="#"
  62. :before-upload="fjBeforeUpload"
  63. :on-remove="handleRemove"
  64. :on-preview="handlePreview"
  65. :before-remove="beforeRemove"
  66. :show-file-list="true"
  67. :file-list="fjfileList"
  68. :http-request="fileRequest">
  69. <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button>
  70. </el-upload>
  71. <ul v-show="!!fjfileList.length" ></ul>
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="12">
  75. <el-form-item label="联系人" prop="ContactPerson">
  76. <el-input v-model="formData.ContactPerson" placeholder="请输入联系人" clearable :style="{width: '100%'}">
  77. </el-input>
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="12">
  81. <el-form-item label="联系电话" prop="ContactTel">
  82. <el-input v-model="formData.ContactTel" placeholder="请输入联系电话" clearable :style="{width: '100%'}">
  83. </el-input>
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="24" style="text-align:center">
  87. <el-form-item size="large">
  88. <el-button type="primary" @click="submitForm">提交</el-button>
  89. <el-button @click="resetForm">重置</el-button>
  90. </el-form-item>
  91. </el-col>
  92. </el-row>
  93. </el-form>
  94. <!-- 选择人员对话框 -->
  95. <el-dialog :title="tctitle" :visible.sync="open" width="1000px" append-to-body>
  96. <SelectRen ref="renlist"/>
  97. <div slot="footer" class="dialog-footer">
  98. <el-button @click="cancel">取 消</el-button>
  99. <el-button type="primary" @click="submitRen">选 定</el-button>
  100. </div>
  101. </el-dialog>
  102. <el-dialog :title="tctitle" :visible.sync="open1" width="20%" append-to-body style="size: 30px">
  103. <el-tree
  104. :data="deptOptions"
  105. show-checkbox
  106. default-expand-all
  107. ref="dept"
  108. node-key="id"
  109. empty-text="加载中,请稍后"
  110. :props="defaultProps"
  111. ></el-tree>
  112. <div slot="footer" class="dialog-footer">
  113. <el-button type="primary" @click="getDeptAllCheckedKeys">确 定</el-button>
  114. <el-button @click="cancel">取 消</el-button>
  115. </div>
  116. </el-dialog>
  117. </div>
  118. </template>
  119. <script>
  120. import SelectRen from '@/components/SelectRen';
  121. import { addtzfs,uploadfj } from "@/api/system/tzgl/tzfs";
  122. import { treeselect } from "@/api/system/dept";
  123. import Treeselect from "@riophae/vue-treeselect";
  124. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  125. import Editor from '@/components/Editor';
  126. export default {
  127. components: {
  128. SelectRen,
  129. Treeselect,
  130. Editor,
  131. },
  132. props: [],
  133. data() {
  134. return {
  135. formData: {
  136. Title: '',
  137. Content: '',
  138. ContactPerson: '',
  139. ContactTel: '',
  140. RecvAccount:'',
  141. RecvPerson:'',
  142. deptId:'',
  143. deptflg:0,
  144. fileName:'',
  145. filePath:'',
  146. },
  147. rules: {
  148. deptId:[{
  149. required:true,
  150. message:'请选择收件单位',
  151. trigger:'blur'
  152. }],
  153. RecvPerson:[{
  154. required:true,
  155. message:'请选择收件人',
  156. trigger:'blur'
  157. }],
  158. deptflg:[{
  159. required:true,
  160. message:'请选择收件主体',
  161. trigger:'blur'
  162. }],
  163. Title: [{
  164. required: true,
  165. message: '请输入通知标题',
  166. trigger: 'blur'
  167. }],
  168. Content: [{
  169. required: true,
  170. message: '请输入通知内容',
  171. trigger: 'blur'
  172. }],
  173. SendPerson: [{
  174. required: true,
  175. message: '请输入收件人',
  176. trigger: 'blur'
  177. }],
  178. SendAccount: [{
  179. required: true,
  180. message: '请输入收件单位',
  181. trigger: 'blur'
  182. }],
  183. ContactPerson: [{
  184. required: true,
  185. message: '请输入联系人',
  186. trigger: 'blur'
  187. }],
  188. ContactTel: [{
  189. required: true,
  190. message: '请输入联系电话',
  191. trigger: 'blur'
  192. }],
  193. },
  194. fjfileList: [],
  195. fileList:[],
  196. // 弹出层标题
  197. tctitle: "",
  198. // 是否显示弹出层
  199. open: false,
  200. open1:false,
  201. filterText: '', //人员选择器中的 筛选
  202. // 部门树选项
  203. deptOptions: [],
  204. defaultProps: {
  205. children: "children",
  206. label: "label"
  207. },
  208. // 部门id
  209. depid:[],
  210. depname:[],
  211. deptflgOptions: [{
  212. "label": "个人",
  213. "value": 0
  214. }, {
  215. "label": "单位",
  216. "value": 1
  217. }],
  218. showsjr:true,
  219. showdw:false,
  220. }
  221. },
  222. // computed: {},
  223. // watch: {},
  224. created() {
  225. this.getTreeselect();
  226. },
  227. //mounted() {},
  228. methods: {
  229. submitForm() {
  230. this.$refs['elForm'].validate(valid => {
  231. // TODO 提交表单
  232. console.log( this.formData.RecvAccount)
  233. console.log("this.deptid")
  234. if (this.formData.deptflg === 1) {
  235. this.formData.deptId = "";
  236. // this.depid = this.getDeptAllCheckedKeys();
  237. this.depid = this.formData.RecvAccount;
  238. if (this.depid.length > 0) {
  239. for (let i = 0; i < this.depid.length; i++) {
  240. if (this.depid!=100&&this.depid!=101){
  241. this.formData.deptId += this.depid[i] + ',';
  242. }
  243. }
  244. }
  245. }
  246. addtzfs(this.formData).then(response => {
  247. if (response.code === 200) {
  248. this.msgSuccess("发送成功");
  249. this.open = false;
  250. this.open1 = false;
  251. this.getTreeselect();
  252. this.reset();
  253. }
  254. });
  255. })
  256. },
  257. // 表单重置
  258. reset() {
  259. this.formData = {
  260. Title: '',
  261. Content: '',
  262. ContactPerson: '',
  263. ContactTel: '',
  264. RecvAccount: '',
  265. RecvPerson: '',
  266. deptId: '',
  267. deptflg: 0,
  268. fileName: '',
  269. filePath: '',
  270. };
  271. this.showsjr = true;
  272. this.showdw = false;
  273. this.depid = [];
  274. this.deptOptions = [];
  275. this.open = false;
  276. this.open1 = false;
  277. this.fjfileList = [];
  278. this.fileList = [];
  279. this.depname=[];
  280. this.resetForm();
  281. },
  282. resetForm() {
  283. this.depname=[];
  284. this.formData.RecvPerson=[];
  285. this.formData.RecvAccount=[];
  286. this.$refs['elForm'].resetFields()
  287. },
  288. /** ---------------收件人---------------*/
  289. handleSelect() {
  290. this.open = true;
  291. this.tctitle = "选择收件人";
  292. },
  293. submitRen(){
  294. this.formData.RecvPerson =this.$refs.renlist.names.join(',');
  295. this.formData.RecvAccount=this.$refs.renlist.accounts.join(',');
  296. this.open = false;
  297. },
  298. watch: {
  299. /** 人员选择器中的 筛选 */
  300. filterText(val) {
  301. this.$refs.tree.filter(val);
  302. }
  303. },
  304. /** ---------------收件人end---------------*/
  305. cancel() {
  306. this.open = false;
  307. this.open1 = false;
  308. this.filterText='';
  309. },
  310. handledept() {
  311. this.open1 = true;
  312. this.tctitle = "选择部门";
  313. },
  314. /** --------------查询部门下拉树结构---------------- */
  315. getTreeselect() {
  316. treeselect().then(response => {
  317. this.deptOptions = response.data;
  318. var a=this.deptOptions;
  319. for (let i = 0; i <a.length ; i++) {
  320. console.log( this.deptOptions[i].children[0].id)
  321. console.log(a[i].id)
  322. }
  323. });
  324. },
  325. // 筛选节点
  326. filterNode(value, data) {
  327. if (!value) return true;
  328. return data.label.indexOf(value) !== -1;
  329. },
  330. // 节点单击事件
  331. handleNodeClick(data) {
  332. this.queryParams.deptId = data.id;
  333. },
  334. /** 根据角色ID查询部门树结构 */
  335. getRoleDeptTreeselect(roleId) {
  336. roleDeptTreeselect(roleId).then(response => {
  337. this.deptOptions = response.depts;
  338. this.$refs.dept.setCheckedKeys(response.checkedKeys);
  339. });
  340. },
  341. /** 查询部门树结构 */
  342. getDeptTreeselect() {
  343. deptTreeselect().then(response => {
  344. this.deptOptions = response.data;
  345. });
  346. },
  347. // 所有部门节点数据
  348. getDeptAllCheckedKeys() {
  349. // 目前被选中的部门节点
  350. let checkedKeys = this.$refs.dept.getHalfCheckedKeys();
  351. // 半选中的部门节点
  352. let halfCheckedKeys = this.$refs.dept.getCheckedKeys();
  353. let a= this.$refs.dept.getCheckedNodes();
  354. var q=this.deptOptions;
  355. let e="";
  356. for (let w = 0; w <q.length ; w++) {
  357. e += q[w].children[w].id
  358. }
  359. for (let i = 0; i <a.length ; i++) {
  360. if (a[i].id!=100&&a[i].id!=e){
  361. this.depname.push(a[i].label)
  362. this.depid.push(a[i].id)
  363. }
  364. }
  365. console.log(a)
  366. checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
  367. this.formData.RecvAccount =this.depid;
  368. this.formData.RecvPerson = this.depname ;
  369. this.open1=false;
  370. this.depname=[];
  371. this.depid=[];
  372. return halfCheckedKeys;
  373. },
  374. /** 根据角色ID查询部门树结构 */
  375. getRoleDeptTreeselect(roleId) {
  376. roleDeptTreeselect(roleId).then(response => {
  377. this.deptOptions = response.depts;
  378. this.$refs.dept.setCheckedKeys(response.checkedKeys);
  379. });
  380. },
  381. /** ---------------查询部门下拉树结构end----------------- */
  382. /** ---------------附件----------------- */
  383. fjBeforeUpload(file) {
  384. let isRightSize = file.size / 1024 / 1024 < 50
  385. if (!isRightSize) {
  386. this.$message.error('文件大小超过 50MB')
  387. }
  388. return isRightSize
  389. },
  390. handlePreview(file) {
  391. // 预览,一些文件因为格式问题无法预览。推荐使用a标签,src为文件的下载地址,点击即可下载,参照录音
  392. window.open(file.filePath);
  393. },
  394. handleSuccess(file, fileInfo) {
  395. console.log(fileInfo);
  396. this.fileList.push({
  397. name: fileInfo.name,
  398. uuid: fileInfo.uid,
  399. filePath: fileInfo.url
  400. });
  401. },
  402. handleRemove(file) {
  403. // 移除
  404. this.fjfileList.forEach((item, index) => {
  405. console.log(item);
  406. if (item.uid === file.uid) {
  407. this.fjfileList.splice(index, 1);
  408. //删除
  409. }
  410. });
  411. },
  412. beforeRemove(file, fileList) {
  413. return this.$confirm(`确定移除 ${ file.name }?`);
  414. },
  415. fileRequest(item) {
  416. let uploadData = new FormData()
  417. uploadData.append('file',item.file)
  418. uploadfj(uploadData).then(response => {
  419. if (response.code === 200) {
  420. this.formData.fileName += response.data.fileName+',';
  421. this.formData.filePath += response.data.filePath+',';
  422. this.fjfileList.push({
  423. name: response.data.fileName,
  424. filePath: process.env.VUE_APP_BASE_API+response.data.filePath
  425. });
  426. this.msgSuccess("上传成功");
  427. }
  428. }).catch(function(e) {
  429. console.log('catch:', e);})
  430. },
  431. /** ---------------附件end----------------- */
  432. agreeChange(val){
  433. let app = this;
  434. this.formData.deptflg=val;
  435. if(val===0)
  436. {
  437. this.showsjr=true;
  438. this.showdw=false;
  439. }
  440. else if(val===1)
  441. {
  442. this.showsjr=false;
  443. this.showdw=true;
  444. }
  445. },
  446. }
  447. };
  448. </script>
  449. <style >
  450. .el-upload__tip {
  451. line-height: 1.2;
  452. }
  453. .el-input-group__append, .el-input-group__prepend{
  454. background: #188efd !important;
  455. color: #fff !important;
  456. }
  457. </style>