form.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  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="entrustName" v-if="userinfo.tenantType == 1">
  15. <mySelectButton size='large' style="width:100%" @click="handleSelect" >
  16. <div style="width:100%">
  17. <el-autocomplete style="width:100%" v-model="ruleForm.entrustName" ref="client" value-key="name" :fetch-suggestions="querySearch" v-SelectLazyLoading="loadClient"
  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="departmentId" 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.number="ruleForm.headId" filterable remote clearable placeholder="请选择"
  34. :loading="personnelList.loading" v-SelectLazyLoading="loadHead" :remote-method="remoteMethod">
  35. <el-option v-for="item in personnelList.data" :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" v-if="!ruleForm.id">
  40. <mySelectButton size='large' style="width:100%" @click="addEvent" >
  41. <div style="width:100%">
  42. <el-select style="width:100%" v-model="ruleForm.eventId" @change="changeEvent" filterable remote :disabled="eventList.disabled" clearable placeholder="请选择"
  43. :loading="eventList.loading" v-SelectLazyLoading="loadEvent" :remote-method="remoteEvent">
  44. <el-option v-for="item in eventList.data" :key="item.id" :label="item.name" :value="item.id">
  45. </el-option>
  46. </el-select>
  47. </div>
  48. </mySelectButton>
  49. </el-form-item>
  50. <template v-if="(ruleForm.id && !(ruleForm.eventIds && ruleForm.eventIds.length)) || !ruleForm.id">
  51. <div>
  52. <el-form-item label="应用场景" prop="scenarioIds">
  53. <el-checkbox-group v-model="ruleForm.scenarioIds" @change="onChange" :disabled="Boolean(ruleForm.eventId)">
  54. <el-checkbox v-for="item in commonData" :key="item.id"
  55. :label="parseInt(item.id)">{{ item.name }}</el-checkbox>
  56. </el-checkbox-group>
  57. </el-form-item>
  58. <el-form-item label="调查类型" prop="matterIds" v-if="show == true">
  59. <el-checkbox-group v-model="ruleForm.matterIds">
  60. <template >
  61. <el-checkbox v-for="(item, index) in dictAssociateData" :key="index" :label="parseInt(item.id)">
  62. {{ item.name }}
  63. </el-checkbox>
  64. </template>
  65. </el-checkbox-group>
  66. </el-form-item>
  67. </div>
  68. </template>
  69. <template>
  70. <div>
  71. <el-form-item label="产品类别/产品" prop="productId" v-if="$permission('/workspace/product')">
  72. <div>
  73. <div v-if="ruleForm.products">
  74. {{ ruleForm.products.name }}
  75. <span style="color:blue">
  76. ({{ ruleForm.products.treeType==2?'产品':'产品类别' }})
  77. </span>
  78. <span><i class="el-icon-error cursor_pointer" @click="delProduct"></i></span>
  79. </div>
  80. <el-button size="small" v-else @click="choseProduct">+ 选择</el-button>
  81. </div>
  82. </el-form-item>
  83. <el-form-item label="分类架构" prop="structureId" v-if="ruleForm.products && ruleForm.products.fieldId && $permission('/workspace/product')">
  84. <my-select-Tree style="width:100%" :options="structureList" :props="StructureProp" v-model="ruleForm.structureId"></my-select-Tree>
  85. </el-form-item>
  86. </div>
  87. </template>
  88. <el-row :gutter="24">
  89. <el-col :span="12">
  90. <el-form-item label="合同号" prop="contractNo">
  91. <el-input v-model="ruleForm.contractNo" placeholder="请输入合同号"></el-input>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :span="12">
  95. <el-form-item label="内部案卷" prop="volumeNumber">
  96. <el-input v-model="ruleForm.volumeNumber" placeholder="请输入内部案卷"></el-input>
  97. </el-form-item>
  98. </el-col>
  99. </el-row>
  100. <el-row :gutter="24">
  101. <el-col :span="12">
  102. <el-form-item label="委案日" prop="commissionCaseDay">
  103. <el-date-picker v-model="ruleForm.commissionCaseDay" value-format="yyyy-MM-dd" type="date" placeholder="请选择委案日"
  104. class="width_100"></el-date-picker>
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="12">
  108. <el-form-item label="处理状态" prop="status">
  109. <el-select v-model="ruleForm.status" placeholder="请输入处理状态" class="width_100">
  110. <el-option value="0" label="处理中"></el-option>
  111. <el-option value="1" label="已完成"></el-option>
  112. </el-select>
  113. </el-form-item>
  114. </el-col>
  115. </el-row>
  116. <el-row :gutter="24">
  117. <el-col :span="12">
  118. <el-form-item label="是否更新" prop="ifUpdate">
  119. <el-select v-model="ruleForm.ifUpdate" placeholder="请选择是否更新" class="width_100">
  120. <el-option :value="false" label="否"></el-option>
  121. <el-option :value="true" label="是"></el-option>
  122. </el-select>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :span="12" v-if="ruleForm.ifUpdate">
  126. <el-form-item label="更新周期" required>
  127. <el-select v-model="ruleForm.updateTime" @change="getDateType" placeholder="请选择更新周期" class="width_100">
  128. <el-option value="day" label="每天"></el-option>
  129. <el-option value="week" label="每周"></el-option>
  130. <el-option value="month" label="每月"></el-option>
  131. <el-option value="year" label="每年"></el-option>
  132. </el-select>
  133. </el-form-item>
  134. </el-col>
  135. </el-row>
  136. <el-row :gutter="24">
  137. <el-col :span="24">
  138. <el-form-item label="更新具体时间" v-if="ruleForm.ifUpdate && ruleForm.updateTime" >
  139. <my-Time-Choose :type="ruleForm.updateTime" @value="getValue" :cron="ruleForm.crons" style="width:300px"></my-Time-Choose>
  140. </el-form-item>
  141. </el-col>
  142. </el-row>
  143. <el-form-item label="备注" prop="description">
  144. <el-input v-model="ruleForm.description" placeholder="请输入备注" type="textarea"></el-input>
  145. </el-form-item>
  146. </el-form>
  147. </el-main>
  148. <el-footer class="footer-common">
  149. <el-button @click="close">取 消</el-button>
  150. <el-button type="primary" @click="submit" :loading="loading">确 定</el-button>
  151. </el-footer>
  152. </el-container>
  153. </el-drawer>
  154. <el-dialog title="选择委托方" :visible.sync="visible" width="800px" append-to-body destroy-on-close :before-close="close2"
  155. top="10vh">
  156. <ClientTable :choseClient="true" @getClient="getClient"></ClientTable>
  157. </el-dialog>
  158. <el-dialog title="选择产品或产品类别" :visible.sync="productVisible" width="1000px" append-to-body destroy-on-close :before-close="closeProduct">
  159. <div style="height:550px">
  160. <product :isChoose="true" @chooseItem="chooseItem"></product>
  161. </div>
  162. </el-dialog>
  163. <addEvent ref="addEvent" @isSuccess="handleSuccess"></addEvent>
  164. </div>
  165. </template>
  166. <script>
  167. import ClientTable from '@/views/client'
  168. import { mapGetters } from 'vuex';
  169. import product from '@/views/product/components/index.vue'
  170. import addEvent from '@/views/event/components/dialog/addEvent.vue';
  171. export default {
  172. components: {
  173. ClientTable,
  174. product,
  175. addEvent
  176. },
  177. props: {
  178. commonData: Array
  179. },
  180. data() {
  181. return {
  182. //抽屉标题
  183. title: '',
  184. //抽屉开关标识
  185. drawer: false,
  186. //表单数据
  187. ruleForm: {},
  188. //表单规则
  189. rules: {},
  190. //控制选择委托方弹窗
  191. visible: false,
  192. //部门列表
  193. departmentList: [],
  194. //人员列表
  195. personnelList: {
  196. queryParams:{
  197. current:1,
  198. size:10
  199. },
  200. data:[]
  201. },
  202. //确认按钮
  203. loading: false,
  204. //显示调查类型
  205. show: false,
  206. //调查类型列表
  207. dictAssociateData: [],
  208. //用来获取调查类型
  209. test: {
  210. value: '1',
  211. type: 'ENTERPRISE_APPLICATION_SCENARIO',
  212. flag: 1
  213. },
  214. //事件列表
  215. eventList:{
  216. queryParams:{
  217. current:1,
  218. size:10
  219. },
  220. data:[]
  221. },
  222. //选择产品或产品类别
  223. productVisible:false,
  224. //委托方
  225. clientList:{
  226. queryParams:{
  227. current:1,
  228. size:10
  229. },
  230. data:[],
  231. cb:null
  232. }
  233. };
  234. },
  235. watch: {},
  236. computed: {
  237. ...mapGetters(['userinfo'])
  238. },
  239. created() { },
  240. mounted() {
  241. },
  242. methods: {
  243. //切换更新周期
  244. getDateType(val){
  245. this.ruleForm.crons = ''
  246. },
  247. getValue(val){
  248. if (this.ruleForm.dateType=='') {
  249. this.$message.error('请先选择更新周期')
  250. return false
  251. }
  252. this.ruleForm.crons=val
  253. },
  254. //获取架构id
  255. getStructureId(val){
  256. },
  257. //获取选中的值
  258. chooseItem({row,type}){
  259. this.ruleForm.products = {
  260. treeType:type,
  261. fieldId:row.id,
  262. name:row.name,
  263. valueIds:[]
  264. }
  265. this.closeProduct()
  266. },
  267. //删除选择的产品或产品类别
  268. delProduct(){
  269. this.ruleForm.products = null
  270. this.$forceUpdate()
  271. // this.ruleForm.products=null
  272. },
  273. //打开选择产品或产品类别弹窗
  274. choseProduct(){
  275. this.productVisible = true
  276. },
  277. //关闭弹窗
  278. closeProduct(){
  279. this.productVisible = false
  280. },
  281. //打开弹窗
  282. async open(form, title) {
  283. this.ruleForm = JSON.parse(JSON.stringify(form))
  284. //获取部门列表
  285. this.getDepartment()
  286. if(this.ruleForm.scenarioIds && this.ruleForm.scenarioIds.length!=0){
  287. this.show=true
  288. this.onChange()
  289. }else{
  290. this.ruleForm.scenarioIds = []
  291. this.show=false
  292. }
  293. if(!this.ruleForm.id){
  294. this.eventList.data = []
  295. this.eventList.name = ''
  296. this.eventList.disabled = false
  297. if(this.ruleForm.eventId){
  298. this.eventList.disabled = true
  299. this.eventList.data.push({
  300. id:this.ruleForm.eventId,
  301. name:this.ruleForm.eventName,
  302. })
  303. }else{
  304. this.getEventList()
  305. }
  306. }
  307. this.personnelList.data = []
  308. this.personnelList.queryParams.name = ''
  309. if(this.ruleForm.headId){
  310. this.personnelList.queryParams.id = this.ruleForm.headId
  311. await this.getPersonnelList(1)
  312. this.personnelList.queryParams.id = null
  313. }
  314. //获取人员列表
  315. this.getPersonnelList()
  316. this.title = title
  317. this.drawer = true
  318. },
  319. //关闭抽屉
  320. close() {
  321. this.drawer = false
  322. this.clientList.queryParams.name = ''
  323. this.personnelList.queryParams.name = ''
  324. },
  325. //获取部门列表
  326. getDepartment() {
  327. this.$api.getPermissionDepartmentList().then((response) => {
  328. this.departmentList = response.data;
  329. });
  330. },
  331. /**
  332. * 事件
  333. */
  334. //打开事件弹窗
  335. addEvent(){
  336. this.$refs.addEvent.open(null, 1)
  337. },
  338. //事件新增成功
  339. handleSuccess(){
  340. this.eventList.data=[]
  341. this.eventList.queryParams.current = 1
  342. this.eventList.name = ''
  343. this.getEventList()
  344. },
  345. //切换事件
  346. changeEvent(val){
  347. if(!val){
  348. this.ruleForm.scenarioIds = []
  349. this.show = false
  350. this.ruleForm.matterIds = []
  351. return
  352. }
  353. var obj = this.eventList.data.find(item=>{
  354. return item.id == val
  355. })
  356. if(obj){
  357. this.ruleForm.scenarioIds = [obj.scenarioId]
  358. this.show = true
  359. this.onChange()
  360. }
  361. },
  362. //懒加载事件
  363. loadEvent(){
  364. if(this.eventList.queryParams.current * this.eventList.queryParams.size>=this.eventList.queryParams.total){
  365. return false
  366. }
  367. this.eventList.queryParams.current += 1
  368. this.getEventList()
  369. },
  370. //远程搜索
  371. remoteEvent(query){
  372. this.eventList.data=[]
  373. this.eventList.queryParams.current = 1
  374. this.eventList.name = query
  375. this.getEventList()
  376. },
  377. //获取事件列表
  378. async getEventList(){
  379. this.eventList.loading = true;
  380. let params = {
  381. ...this.eventList.queryParams,//分页信息
  382. searchQuery:this.eventList.name?`name=${this.eventList.name}`:'',//检索条件
  383. orderDTOList: [
  384. {
  385. orderBy: "createTime",
  386. orderType: 1
  387. },
  388. ]//排序
  389. }
  390. await this.$api.queryEvent(params).then(response => {
  391. if(response.code == 200){
  392. this.eventList.loading = false;
  393. this.eventList.data.push(...response.data.data)
  394. this.eventList.queryParams.total = response.data.total
  395. }
  396. })
  397. },
  398. //获取人员列表(懒加载)
  399. loadHead(){
  400. if(this.personnelList.queryParams.current * this.personnelList.queryParams.size>=this.personnelList.queryParams.total){
  401. return false
  402. }
  403. this.personnelList.queryParams.current += 1
  404. this.getPersonnelList()
  405. },
  406. async getPersonnelList(type) {
  407. this.personnelList.loading = true;
  408. await this.$api.getPermissionPersonnel(this.personnelList.queryParams).then((response) => {
  409. if(response.code == 200){
  410. this.personnelList.loading = false;
  411. if(!type){
  412. var index = response.data.findIndex(item=>{
  413. return item.id == this.ruleForm.headId
  414. })
  415. if(index!=-1){
  416. response.data.splice(index,1)
  417. }
  418. this.personnelList.queryParams.total=response.pageColumn.total
  419. }
  420. this.personnelList.data.push(...response.data)
  421. }
  422. })
  423. },
  424. //人员远程搜索
  425. remoteMethod(query) {
  426. this.personnelList.data=[]
  427. this.personnelList.queryParams.current = 1
  428. this.personnelList.queryParams.name = query
  429. this.getPersonnelList()
  430. },
  431. //远程搜索委托方(建议调取接口获取)
  432. async querySearch(queryString, cb) {
  433. this.clientList.queryParams.current = 1
  434. this.clientList.queryParams.name = queryString
  435. this.clientList.data = []
  436. this.clientList.cb = cb
  437. await this.getClientList()
  438. // 调用 callback 返回建议列表的数据
  439. // cb(this.clientList.data);
  440. },
  441. loadClient(){
  442. if(this.clientList.queryParams.current * this.clientList.queryParams.size>=this.clientList.queryParams.total){
  443. return false
  444. }
  445. this.clientList.queryParams.current += 1
  446. this.getClientList()
  447. },
  448. //获取委托方
  449. async getClientList(){
  450. await this.$api.getAdminClientList(this.clientList.queryParams).then(res => {
  451. if (res.code == 200) {
  452. this.clientList.data.push(...res.data.records)
  453. this.clientList.queryParams.total = res.data.total
  454. this.clientList.cb(this.clientList.data);
  455. }
  456. })
  457. },
  458. //输入框输入事件(委托方)
  459. input() {
  460. this.$set(this.ruleForm, 'entrustId', -1)
  461. },
  462. //切换选择委托方
  463. handleChange(row) {
  464. this.$set(this.ruleForm, 'entrustId', row.id)
  465. this.$set(this.ruleForm, 'entrustName', row.name)
  466. this.close2()
  467. },
  468. //打开选择委托方弹窗
  469. handleSelect() {
  470. this.visible = true
  471. },
  472. //获取委托方信息
  473. getClient(row) {
  474. this.$set(this.ruleForm, 'entrustId', row.id)
  475. this.$set(this.ruleForm, 'entrustName', row.name)
  476. this.close2()
  477. },
  478. //关闭委托方弹窗
  479. close2() {
  480. this.visible = false
  481. },
  482. //调查类型选择切换
  483. onChange() {
  484. if (this.ruleForm.scenarioIds.length != 0) {
  485. this.show = true
  486. this.$api.getMatter(this.ruleForm.scenarioIds).then(response => {
  487. this.dictAssociateData = response.data.data
  488. })
  489. } else {
  490. this.show = false
  491. }
  492. },
  493. //提交数据
  494. submit() {
  495. this.$refs.ruleForm.validate((valid) => {
  496. if (valid) {
  497. this.show = false
  498. this.loading = true
  499. this.ruleForm.trees = []
  500. if(this.ruleForm.products){
  501. this.ruleForm.trees.push(this.ruleForm.products)
  502. }
  503. var scenarioIds = JSON.parse(JSON.stringify(this.ruleForm.scenarioIds))
  504. if(this.ruleForm.eventId){
  505. this.ruleForm.events = []
  506. this.ruleForm.scenarioIds = []
  507. this.ruleForm.matterIds.forEach(item=>{
  508. this.ruleForm.events.push(
  509. {
  510. matterId:item,
  511. scenarioId:scenarioIds[0],
  512. eventId:this.ruleForm.eventId
  513. }
  514. )
  515. })
  516. }
  517. if (this.ruleForm.id) {
  518. this.$api.updatePatentProject(this.ruleForm).then(response => {
  519. this.loading = false
  520. this.$message.success('编辑成功')
  521. this.$emit('submit', 0)
  522. this.close()
  523. }).catch(error => {
  524. this.loading = false
  525. })
  526. } else {
  527. this.$api.addPatentProject(this.ruleForm).then(response => {
  528. this.loading = false
  529. this.$message.success('新增成功')
  530. this.$emit('submit', 1)
  531. this.close()
  532. }).catch(error => {
  533. this.ruleForm.scenarioIds = JSON.parse(JSON.stringify(scenarioIds))
  534. this.show = true
  535. this.loading = false
  536. })
  537. }
  538. }
  539. })
  540. },
  541. },
  542. };
  543. </script>
  544. <style lang="scss" scoped></style>