form.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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="parseInt(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 v-for="item in $constants.updateCycle" :key="item.value" :value="item.value" :label="item.label"></el-option>
  129. </el-select>
  130. </el-form-item>
  131. </el-col>
  132. </el-row>
  133. <el-row :gutter="24">
  134. <el-col :span="24">
  135. <el-form-item label="更新具体时间" v-if="ruleForm.ifUpdate && ruleForm.updateTime" >
  136. <my-Time-Choose :type="ruleForm.updateTime" @value="getValue" :cron="ruleForm.crons" style="width:300px"></my-Time-Choose>
  137. </el-form-item>
  138. </el-col>
  139. </el-row>
  140. <el-form-item label="附件" prop="systemFileList">
  141. <myUpload :file-list="ruleForm.systemFileList" @on-change="onchangeFile" @on-remove="onRemove" style="height: 180px;" :autoUpload="true"></myUpload>
  142. </el-form-item>
  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="true" :close-on-click-modal="false" 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="true" :close-on-click-modal="false" 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. import { cron } from "@/utils/model/time/mixins";
  172. export default {
  173. components: {
  174. ClientTable,
  175. product,
  176. addEvent
  177. },
  178. mixins:[cron],
  179. props: {
  180. commonData: Array
  181. },
  182. data() {
  183. return {
  184. //抽屉标题
  185. title: '',
  186. //抽屉开关标识
  187. drawer: false,
  188. //表单数据
  189. ruleForm: {},
  190. //表单规则
  191. rules: {},
  192. //控制选择委托方弹窗
  193. visible: false,
  194. //部门列表
  195. departmentList: [],
  196. //人员列表
  197. personnelList: {
  198. queryParams:{
  199. current:1,
  200. size:10
  201. },
  202. data:[]
  203. },
  204. //确认按钮
  205. loading: false,
  206. //显示调查类型
  207. show: false,
  208. //调查类型列表
  209. dictAssociateData: [],
  210. //用来获取调查类型
  211. test: {
  212. value: '1',
  213. type: 'ENTERPRISE_APPLICATION_SCENARIO',
  214. flag: 1
  215. },
  216. //事件列表
  217. eventList:{
  218. queryParams:{
  219. current:1,
  220. size:10
  221. },
  222. data:[]
  223. },
  224. //选择产品或产品类别
  225. productVisible:false,
  226. //产品或产品类别架构
  227. structureList:[],
  228. StructureProp:{
  229. value:'id',
  230. label: 'name',
  231. children: 'child'
  232. },
  233. //委托方
  234. clientList:{
  235. queryParams:{
  236. current:1,
  237. size:10
  238. },
  239. data:[],
  240. cb:null
  241. },
  242. };
  243. },
  244. watch: {},
  245. computed: {
  246. ...mapGetters(['userinfo'])
  247. },
  248. created() { },
  249. mounted() {
  250. },
  251. methods: {
  252. //切换更新周期
  253. getDateType(val){
  254. this.ruleForm.crons = ''
  255. },
  256. getValue(val){
  257. if (this.ruleForm.dateType=='') {
  258. this.$message.error('请先选择更新周期')
  259. return false
  260. }
  261. this.ruleForm.crons=val
  262. },
  263. //获取架构id
  264. getStructureId(val){
  265. },
  266. //获取选中的值
  267. chooseItem({row,type}){
  268. this.ruleForm.products = {
  269. treeType:type,
  270. fieldId:row.id,
  271. name:row.name,
  272. valueIds:[]
  273. }
  274. this.closeProduct()
  275. this.getFramework()
  276. },
  277. //获取产品架构集合
  278. getFramework(){
  279. let params = {
  280. type: this.ruleForm.products.treeType,//类型:1产品类别,2产品,3技术分类,4自定义树
  281. typeId: this.ruleForm.products.fieldId,//产品或类别id
  282. }
  283. this.$api.queryTreeNodeTree(params).then(res => {
  284. if (res.code == 200) {
  285. this.structureList = res.data.data
  286. }
  287. }).catch(err => {
  288. })
  289. },
  290. //删除选择的产品或产品类别
  291. delProduct(){
  292. this.ruleForm.products = null
  293. this.$forceUpdate()
  294. // this.ruleForm.products=null
  295. },
  296. //打开选择产品或产品类别弹窗
  297. choseProduct(){
  298. this.productVisible = true
  299. },
  300. //关闭弹窗
  301. closeProduct(){
  302. this.productVisible = false
  303. },
  304. //打开弹窗
  305. async open(form, title) {
  306. this.ruleForm = JSON.parse(JSON.stringify(form))
  307. //获取部门列表
  308. this.getDepartment()
  309. if(this.ruleForm.scenarioIds && this.ruleForm.scenarioIds.length!=0){
  310. this.show=true
  311. this.onChange()
  312. }else{
  313. this.ruleForm.scenarioIds = []
  314. this.show=false
  315. }
  316. if(!this.ruleForm.id){
  317. this.eventList.data = []
  318. this.eventList.name = ''
  319. this.eventList.disabled = false
  320. if(this.ruleForm.eventId){
  321. this.eventList.disabled = true
  322. this.eventList.data.push({
  323. id:this.ruleForm.eventId,
  324. name:this.ruleForm.eventName,
  325. })
  326. }else{
  327. this.getEventList()
  328. }
  329. }
  330. this.personnelList.data = []
  331. this.personnelList.queryParams.name = ''
  332. console.log(this.ruleForm)
  333. if(this.ruleForm.headId){
  334. this.personnelList.queryParams.id = this.ruleForm.headId
  335. await this.getPersonnelList(1)
  336. this.personnelList.queryParams.id = null
  337. }
  338. //获取人员列表
  339. this.getPersonnelList()
  340. if(this.ruleForm.crons){
  341. this.ruleForm.updateTime = this.getType(this.ruleForm.crons)
  342. }
  343. this.title = title
  344. this.drawer = true
  345. },
  346. //关闭抽屉
  347. close() {
  348. this.drawer = false
  349. this.clientList.queryParams.name = ''
  350. this.personnelList.queryParams.name = ''
  351. },
  352. //获取部门列表
  353. getDepartment() {
  354. this.$api.getPermissionDepartmentList().then((response) => {
  355. this.departmentList = response.data;
  356. });
  357. },
  358. /**
  359. * 事件
  360. */
  361. //打开事件弹窗
  362. addEvent(){
  363. this.$refs.addEvent.open(null, 1)
  364. },
  365. //事件新增成功
  366. handleSuccess(){
  367. this.eventList.data=[]
  368. this.eventList.queryParams.current = 1
  369. this.eventList.name = ''
  370. this.getEventList()
  371. },
  372. //切换事件
  373. changeEvent(val){
  374. if(!val){
  375. this.ruleForm.scenarioIds = []
  376. this.show = false
  377. this.ruleForm.matterIds = []
  378. return
  379. }
  380. var obj = this.eventList.data.find(item=>{
  381. return item.id == val
  382. })
  383. if(obj){
  384. this.ruleForm.scenarioIds = [obj.scenarioId]
  385. this.show = true
  386. this.onChange()
  387. }
  388. },
  389. //懒加载事件
  390. loadEvent(){
  391. if(this.eventList.queryParams.current * this.eventList.queryParams.size>=this.eventList.queryParams.total){
  392. return false
  393. }
  394. this.eventList.queryParams.current += 1
  395. this.getEventList()
  396. },
  397. //远程搜索
  398. remoteEvent(query){
  399. this.eventList.data=[]
  400. this.eventList.queryParams.current = 1
  401. this.eventList.name = query
  402. this.getEventList()
  403. },
  404. //获取事件列表
  405. async getEventList(){
  406. this.eventList.loading = true;
  407. let params = {
  408. ...this.eventList.queryParams,//分页信息
  409. searchQuery:this.eventList.name?`name=${this.eventList.name}`:'',//检索条件
  410. orderDTOList: [
  411. {
  412. orderBy: "createTime",
  413. orderType: 1
  414. },
  415. ]//排序
  416. }
  417. await this.$api.queryEvent(params).then(response => {
  418. if(response.code == 200){
  419. this.eventList.loading = false;
  420. this.eventList.data.push(...response.data.data)
  421. this.eventList.queryParams.total = response.data.total
  422. }
  423. })
  424. },
  425. //获取人员列表(懒加载)
  426. loadHead(){
  427. if(this.personnelList.queryParams.current * this.personnelList.queryParams.size>=this.personnelList.queryParams.total){
  428. return false
  429. }
  430. this.personnelList.queryParams.current += 1
  431. this.getPersonnelList()
  432. },
  433. async getPersonnelList(type) {
  434. this.personnelList.loading = true;
  435. await this.$api.getPermissionPersonnel(this.personnelList.queryParams).then((response) => {
  436. if(response.code == 200){
  437. this.personnelList.loading = false;
  438. if(!type){
  439. var index = response.data.findIndex(item=>{
  440. return item.id == this.ruleForm.headId
  441. })
  442. if(index!=-1){
  443. response.data.splice(index,1)
  444. }
  445. this.personnelList.queryParams.total=response.pageColumn.total
  446. }
  447. this.personnelList.data.push(...response.data)
  448. }
  449. })
  450. },
  451. //人员远程搜索
  452. remoteMethod(query) {
  453. this.personnelList.data=[]
  454. this.personnelList.queryParams.current = 1
  455. this.personnelList.queryParams.name = query
  456. this.getPersonnelList()
  457. },
  458. //远程搜索委托方(建议调取接口获取)
  459. async querySearch(queryString, cb) {
  460. this.clientList.queryParams.current = 1
  461. this.clientList.queryParams.name = queryString
  462. this.clientList.data = []
  463. this.clientList.cb = cb
  464. await this.getClientList()
  465. // 调用 callback 返回建议列表的数据
  466. // cb(this.clientList.data);
  467. },
  468. loadClient(){
  469. if(this.clientList.queryParams.current * this.clientList.queryParams.size>=this.clientList.queryParams.total){
  470. return false
  471. }
  472. this.clientList.queryParams.current += 1
  473. this.getClientList()
  474. },
  475. //获取委托方
  476. async getClientList(){
  477. await this.$api.getAdminClientList(this.clientList.queryParams).then(res => {
  478. if (res.code == 200) {
  479. this.clientList.data.push(...res.data.records)
  480. this.clientList.queryParams.total = res.data.total
  481. this.clientList.cb(this.clientList.data);
  482. }
  483. })
  484. },
  485. //输入框输入事件(委托方)
  486. input() {
  487. this.$set(this.ruleForm, 'entrustId', -1)
  488. },
  489. //切换选择委托方
  490. handleChange(row) {
  491. this.$set(this.ruleForm, 'entrustId', row.id)
  492. this.$set(this.ruleForm, 'entrustName', row.name)
  493. this.close2()
  494. },
  495. //打开选择委托方弹窗
  496. handleSelect() {
  497. this.visible = true
  498. },
  499. //获取委托方信息
  500. getClient(row) {
  501. this.$set(this.ruleForm, 'entrustId', row.id)
  502. this.$set(this.ruleForm, 'entrustName', row.name)
  503. this.close2()
  504. },
  505. //关闭委托方弹窗
  506. close2() {
  507. this.visible = false
  508. },
  509. //调查类型选择切换
  510. onChange() {
  511. if (this.ruleForm.scenarioIds.length != 0) {
  512. this.show = true
  513. this.$api.getMatter(this.ruleForm.scenarioIds).then(response => {
  514. this.dictAssociateData = response.data.data
  515. })
  516. } else {
  517. this.show = false
  518. }
  519. },
  520. // 上传的文件监听
  521. onchangeFile(file, fileList) {
  522. if(!this.ruleForm.systemFileList){
  523. this.$set(this.ruleForm,'systemFileList',[])
  524. }
  525. if (file.guid) {
  526. let index = this.ruleForm.systemFileList.findIndex(item => {
  527. return item.uid == file.uid
  528. })
  529. if (index != -1) {
  530. this.ruleForm.systemFileList.splice(index, 1, file)
  531. }
  532. } else {
  533. this.ruleForm.systemFileList.push(file.raw)
  534. }
  535. },
  536. // 删除上传的文件
  537. onRemove(file, fileList) {
  538. let index = this.ruleForm.systemFileList.findIndex(item => {
  539. return item.uid == file.uid
  540. })
  541. if (index != -1) {
  542. this.ruleForm.systemFileList.splice(index, 1)
  543. }
  544. },
  545. //提交数据
  546. submit() {
  547. this.$refs.ruleForm.validate((valid) => {
  548. if (valid) {
  549. this.show = false
  550. this.loading = true
  551. this.ruleForm.trees = []
  552. if(this.ruleForm.products){
  553. this.ruleForm.trees.push(this.ruleForm.products)
  554. }
  555. var scenarioIds = JSON.parse(JSON.stringify(this.ruleForm.scenarioIds))
  556. if(this.ruleForm.eventId){
  557. this.ruleForm.events = []
  558. this.ruleForm.scenarioIds = []
  559. this.ruleForm.matterIds.forEach(item=>{
  560. this.ruleForm.events.push(
  561. {
  562. matterId:item,
  563. scenarioId:scenarioIds[0],
  564. eventId:this.ruleForm.eventId
  565. }
  566. )
  567. })
  568. }
  569. // 判断文件是否都上传完毕
  570. var guids = this.$commonJS.checkUploadFile(this.ruleForm.systemFile)
  571. if(!guids){
  572. return false
  573. }
  574. this.ruleForm.fileGuids = guids
  575. if (this.ruleForm.id) {
  576. this.$api.updatePatentProject(this.ruleForm).then(response => {
  577. this.loading = false
  578. this.$message.success('编辑成功')
  579. this.$emit('submit', 0)
  580. this.close()
  581. }).catch(error => {
  582. this.loading = false
  583. })
  584. } else {
  585. this.$api.addPatentProject(this.ruleForm).then(response => {
  586. this.loading = false
  587. this.$message.success('新增成功')
  588. this.$emit('submit', 1)
  589. this.close()
  590. }).catch(error => {
  591. this.ruleForm.scenarioIds = JSON.parse(JSON.stringify(scenarioIds))
  592. this.show = true
  593. this.loading = false
  594. })
  595. }
  596. }
  597. })
  598. },
  599. },
  600. };
  601. </script>
  602. <style lang="scss" scoped></style>