form.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <div>
  3. <el-drawer class="custom-drawer-form" :title="title" size="800px" append-to-body :visible.sync="drawer"
  4. direction="rtl" :before-close="close" destroy-on-close>
  5. <el-container>
  6. <el-main>
  7. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="130px" label-position="left"
  8. class="demo-ruleForm">
  9. <el-form-item label="专题库名称" prop="name">
  10. <el-input v-model="ruleForm.name" placeholder="请输入专题库名称"></el-input>
  11. </el-form-item>
  12. <template>
  13. <div>
  14. <el-form-item label="委托方" prop="name" v-if="userinfo.tenantType == 1">
  15. <mySelectButton size='large' style="width:100%" @click="handleSelect">
  16. <div slot="select" style="width:100%">
  17. <el-autocomplete style="width:100%" v-model="ruleForm.clientName" :fetch-suggestions="querySearch"
  18. @input="input" placeholder="请输入内容" :trigger-on-focus="false" @select="handleChange">
  19. </el-autocomplete>
  20. </div>
  21. </mySelectButton>
  22. </el-form-item>
  23. <el-form-item label="委托部门" prop="name" v-else>
  24. <mySelectTree style="width:100%" v-model="ruleForm.departmentId" :options="departmentList">
  25. </mySelectTree>
  26. </el-form-item>
  27. </div>
  28. </template>
  29. <el-form-item label="负责部门" prop="departmentId">
  30. <mySelectTree style="width:100%" v-model="ruleForm.departmentId" :options="departmentList"></mySelectTree>
  31. </el-form-item>
  32. <el-form-item label="负责人" prop="person">
  33. <el-select style="width:100%" v-model="ruleForm.headId" filterable remote clearable placeholder="请选择"
  34. :loading="loading" v-SelectLazyLoading="lazyLoading" :remote-method="remoteMethod">
  35. <el-option v-for="item in personnelList" :key="item.id" :label="item.name" :value="item.id">
  36. </el-option>
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="事件" prop="event">
  40. <div v-if="showEvent" style="display:flex">
  41. <span>
  42. <el-tag
  43. v-for="tag in ruleForm.eventList"
  44. :key="tag.value"
  45. closable
  46. type='info'
  47. >
  48. {{tag.eventName}} - {{ tag.scenario }}
  49. </el-tag>
  50. </span>
  51. <span style="margin-left:10px">
  52. <my-cascader :options="eventList" @change="change">
  53. <i slot="reference" class="el-icon-circle-plus-outline" style="font-size:20px;"></i>
  54. </my-cascader>
  55. </span>
  56. </div>
  57. </el-form-item>
  58. <el-form-item label="应用场景" prop="scenarioList">
  59. <el-checkbox-group v-model="ruleForm.scenarios" @change="onChange">
  60. <el-checkbox v-for="item in commonData.ENTERPRISE_APPLICATION_SCENARIO" :key="item.value"
  61. :label="parseInt(item.value)">{{ item.label }}</el-checkbox>
  62. </el-checkbox-group>
  63. </el-form-item>
  64. <el-form-item label="调查类型" prop="typeList" v-if="show == true">
  65. <el-checkbox-group v-model="ruleForm.typeList">
  66. <template v-for="(item, index) in dictAssociateData">
  67. <el-checkbox :label="parseInt(item.dictChildValue)">
  68. {{ item.dictChildLabel }}
  69. </el-checkbox>
  70. <div v-if="index === dictAssociateData.length - 1" class="more-data-box">
  71. <el-link v-if="moreData" type="primary" icon="el-icon-arrow-down" @click="handleMoreData(0)">更多
  72. </el-link>
  73. <el-link v-else type="primary" icon="el-icon-arrow-up" @click="handleMoreData(1)">收起</el-link>
  74. </div>
  75. </template>
  76. <div v-show="isShow">
  77. <el-checkbox v-for="item in dictSecondAssociateData" :label="parseInt(item.dictChildValue)">
  78. {{ item.dictChildLabel }}
  79. </el-checkbox>
  80. </div>
  81. </el-checkbox-group>
  82. </el-form-item>
  83. <template>
  84. <div>
  85. <el-form-item label="产品类别/产品" prop="productId" v-if="$permission('/workspace/product')">
  86. <div>
  87. <!-- <mySelectButton size='large' style="width:100%">
  88. <div slot="select" style="width:100%">
  89. <mySelectTree style="width:100%" v-model="ruleForm.departmentId" :options="departmentList">
  90. </mySelectTree>
  91. </div>
  92. </mySelectButton> -->
  93. <div v-if="ruleForm.products">
  94. {{ ruleForm.products.name }}
  95. <span style="color:blue">
  96. ({{ ruleForm.products.treeType==2?'产品':'产品类别' }})
  97. </span>
  98. <span><i class="el-icon-error cursor_pointer" @click="delProduct"></i></span>
  99. </div>
  100. <el-button size="small" v-else @click="choseProduct">+ 选择</el-button>
  101. </div>
  102. </el-form-item>
  103. <el-form-item label="分类架构" prop="structureId" v-if="ruleForm.products && ruleForm.products.fieldId && $permission('/workspace/product')">
  104. <my-select-Tree style="width:100%" :options="structureList" @getValue="getStructureId" :props="StructureProp" :value="ruleForm.structureId"></my-select-Tree>
  105. </el-form-item>
  106. </div>
  107. </template>
  108. <el-row :gutter="24">
  109. <el-col :span="12">
  110. <el-form-item label="合同号" prop="contractNo">
  111. <el-input v-model="ruleForm.contractNo" placeholder="请输入合同号"></el-input>
  112. </el-form-item>
  113. </el-col>
  114. <el-col :span="12">
  115. <el-form-item label="内部案卷" prop="volumeNumber">
  116. <el-input v-model="ruleForm.volumeNumber" placeholder="请输入内部案卷"></el-input>
  117. </el-form-item>
  118. </el-col>
  119. </el-row>
  120. <el-row :gutter="24">
  121. <el-col :span="12">
  122. <el-form-item label="委案日" prop="commissionCaseDay">
  123. <el-date-picker v-model="ruleForm.commissionCaseDay" value-format="yyyy-MM-dd" type="date" placeholder="请选择委案日"
  124. class="width_100"></el-date-picker>
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="12">
  128. <el-form-item label="处理状态" prop="status">
  129. <el-select v-model="ruleForm.status" placeholder="请输入处理状态" class="width_100">
  130. <el-option value="0" label="处理中"></el-option>
  131. <el-option value="1" label="已完成"></el-option>
  132. </el-select>
  133. </el-form-item>
  134. </el-col>
  135. </el-row>
  136. <el-form-item label="备注" prop="description">
  137. <el-input v-model="ruleForm.description" placeholder="请输入备注" type="textarea"></el-input>
  138. </el-form-item>
  139. </el-form>
  140. </el-main>
  141. <el-footer class="footer-common"
  142. v-if="($permission('/workspace/project/modify') || $permission('/workspace/project/add')) && ($r(ruleForm.id, [2]) || userinfo.id == ruleForm.createBy)">
  143. <el-button @click="close">取 消</el-button>
  144. <el-button type="primary" @click="submit" :loading="loading">确 定</el-button>
  145. </el-footer>
  146. </el-container>
  147. </el-drawer>
  148. <el-dialog title="选择委托方" :visible.sync="visible" width="800px" append-to-body destroy-on-close :before-close="close2"
  149. top="10vh">
  150. <ClientTable :choseClient="true" @getClient="getClient"></ClientTable>
  151. </el-dialog>
  152. <el-dialog title="选择产品或产品类别" :visible.sync="productVisible" width="1000px" append-to-body destroy-on-close :before-close="closeProduct">
  153. <div style="height:550px">
  154. <product :isChoose="true" @chooseItem="chooseItem"></product>
  155. </div>
  156. </el-dialog>
  157. </div>
  158. </template>
  159. <script>
  160. import ClientTable from '@/views/client'
  161. import { mapGetters } from 'vuex';
  162. import product from '@/views/product/components/index.vue'
  163. export default {
  164. components: {
  165. ClientTable,
  166. product
  167. },
  168. props: {
  169. commonData: Object
  170. },
  171. data() {
  172. return {
  173. //抽屉标题
  174. title: '',
  175. //抽屉开关标识
  176. drawer: false,
  177. //表单数据
  178. ruleForm: {},
  179. //表单规则
  180. rules: {},
  181. //控制选择委托方弹窗
  182. visible: false,
  183. //部门列表
  184. departmentList: [],
  185. //人员列表
  186. personnelList: [],
  187. //负责人下拉加载
  188. loading: false,
  189. //显示调查类型
  190. show: false,
  191. //显示更多调查类型
  192. isShow: false,
  193. //显示更多和收起按钮
  194. moreData: true,
  195. //调查类型列表
  196. dictAssociateData: [],
  197. //其他调查类型
  198. dictSecondAssociateData: [],
  199. //用来获取调查类型
  200. test: {
  201. value: '1',
  202. type: 'ENTERPRISE_APPLICATION_SCENARIO',
  203. flag: 1
  204. },
  205. //事件列表
  206. eventList:[
  207. {
  208. label:'事件1',
  209. value:'1',
  210. children:[
  211. {
  212. label:'1-1',
  213. value:'3'
  214. }
  215. ]
  216. },
  217. {
  218. label:'事件2',
  219. value:'2'
  220. },
  221. ],
  222. showEvent:true,
  223. //选择产品或产品类别
  224. productVisible:false,
  225. };
  226. },
  227. watch: {},
  228. computed: {
  229. ...mapGetters(['userinfo'])
  230. },
  231. created() { },
  232. mounted() {
  233. },
  234. methods: {
  235. //获取架构id
  236. getStructureId(val){
  237. },
  238. //获取选中的值
  239. chooseItem({row,type}){
  240. this.ruleForm.products = {
  241. treeType:type,
  242. fieldId:row.id,
  243. name:row.name,
  244. valueIds:[]
  245. }
  246. this.closeProduct()
  247. },
  248. //删除选择的产品或产品类别
  249. delProduct(){
  250. this.ruleForm.products = null
  251. this.$forceUpdate()
  252. // this.ruleForm.products=null
  253. },
  254. //打开选择产品或产品类别弹窗
  255. choseProduct(){
  256. this.productVisible = true
  257. },
  258. //关闭弹窗
  259. closeProduct(){
  260. this.productVisible = false
  261. },
  262. //选择事件
  263. change(value){
  264. if(this.ruleForm.eventList){
  265. }else{
  266. this.ruleForm.eventList = []
  267. }
  268. var index = this.ruleForm.eventList.findIndex(item=>{
  269. return item.eventId == value[0] && item.scenarioId == value[1]
  270. })
  271. if(index != -1){
  272. this.$message.warning('该调查类型已存在')
  273. this.showEvent = false
  274. this.$nextTick(()=>{
  275. this.showEvent = true
  276. })
  277. return false
  278. }
  279. var obj = {}
  280. var arr = this.eventList.find(item=>{
  281. return item.value == value[0]
  282. })
  283. obj.eventName = arr.label
  284. obj.eventId = arr.value
  285. if(value.length>1){
  286. var arr2 = arr.children.find(item=>{
  287. return item.value == value[1]
  288. })
  289. obj.scenario = arr2.label
  290. obj.scenarioId = arr2.value
  291. }
  292. this.ruleForm.eventList.push(obj)
  293. this.showEvent = false
  294. this.$nextTick(()=>{
  295. this.showEvent = true
  296. })
  297. },
  298. //打开弹窗
  299. open(form, title) {
  300. //获取部门列表
  301. this.getDepartment()
  302. //获取人员列表
  303. this.getPersonnelList()
  304. this.ruleForm = JSON.parse(JSON.stringify(form))
  305. this.title = title
  306. this.drawer = true
  307. },
  308. //获取部门列表
  309. getDepartment() {
  310. this.$api.getPermissionDepartmentList().then((response) => {
  311. this.departmentList = response.data;
  312. });
  313. },
  314. //获取人员列表
  315. getPersonnelList() {
  316. this.$api.getPermissionPersonnelList().then((response) => {
  317. this.personnelList = response.data
  318. })
  319. },
  320. //关闭抽屉
  321. close() {
  322. this.drawer = false
  323. },
  324. //远程搜索(建议调取接口获取)
  325. querySearch(queryString, cb) {
  326. // var clientList = this.clientList;
  327. // var results = (queryString ? clientList.filter(this.createFilter(queryString)) : clientList).map(item=>{
  328. // return {
  329. // value:item.name,
  330. // name:item.name,
  331. // id:item.id
  332. // }
  333. // });
  334. // // 调用 callback 返回建议列表的数据
  335. // cb(results);
  336. },
  337. createFilter(queryString) {
  338. return (clientList) => {
  339. return (clientList.name && clientList.name.toLowerCase().indexOf(queryString.toLowerCase()) != -1);
  340. };
  341. },
  342. //输入框输入事件(委托方)
  343. input() {
  344. this.$set(this.ruleForm, 'entrustId', -1)
  345. },
  346. //切换选择委托方
  347. handleChange(row) {
  348. this.$set(this.ruleForm, 'entrustId', row.id)
  349. this.$set(this.ruleForm, 'clientName', row.name)
  350. this.close2()
  351. },
  352. //打开选择委托方弹窗
  353. handleSelect() {
  354. this.visible = true
  355. },
  356. //获取委托方信息
  357. getClient(row) {
  358. this.$set(this.ruleForm, 'entrustId', row.id)
  359. this.$set(this.ruleForm, 'clientName', row.name)
  360. this.close2()
  361. },
  362. //关闭委托方弹窗
  363. close2() {
  364. this.visible = false
  365. },
  366. //负责人远程搜索
  367. remoteMethod(query) {
  368. },
  369. //负责人下拉懒加载
  370. lazyLoading() {
  371. },
  372. //调查类型选择切换
  373. onChange() {
  374. if (this.ruleForm.scenarioList.length != 0) {
  375. this.show = true
  376. this.test.value = this.ruleForm.scenarioList.toString()
  377. this.test.flag = 1
  378. this.$api.getDictTreeByParentDictValue(this.test).then(response => {
  379. this.dictAssociateData = response.data
  380. this.test.value = this.ruleForm.scenarioList.toString()
  381. this.test.flag = 0
  382. this.$api.getDictTreeByParentDictValue(this.test).then(response => {
  383. this.dictSecondAssociateData = response.data
  384. })
  385. })
  386. } else {
  387. this.show = false
  388. }
  389. },
  390. //调查类型展开收起
  391. handleMoreData(type) {
  392. if (type === 0) {
  393. this.isShow = true
  394. this.test.value = this.ruleForm.scenarioList.toString()
  395. this.test.flag = 0
  396. this.$api.getDictTreeByParentDictValue(this.test).then(response => {
  397. this.dictSecondAssociateData = response.data
  398. })
  399. } else if (type === 1) {
  400. this.isShow = false
  401. }
  402. this.moreData = !this.moreData
  403. },
  404. //提交数据
  405. submit() {
  406. this.$refs.ruleForm.validate((valid) => {
  407. if (valid) {
  408. this.show = false
  409. this.loading = true
  410. if (this.ruleForm.id) {
  411. this.$api.editProject(this.ruleForm).then(response => {
  412. this.loading = false
  413. this.$message.success('编辑成功')
  414. this.$emit('submit', 0)
  415. this.close()
  416. }).catch(error => {
  417. this.loading = false
  418. })
  419. } else {
  420. this.$api.addProject(this.ruleForm).then(response => {
  421. this.loading = false
  422. let permissions = this.permissions
  423. permissions[response.data] = 0
  424. this.$store.commit('SET_PERMISSIONS', permissions)
  425. this.$message.success('新增成功')
  426. this.$emit('submit', 1)
  427. this.close()
  428. }).catch(error => {
  429. this.show = true
  430. this.loading = false
  431. })
  432. }
  433. }
  434. })
  435. },
  436. },
  437. };
  438. </script>
  439. <style lang="scss" scoped></style>