form.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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.personnelId" 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="scenarioList">
  40. <el-checkbox-group v-model="ruleForm.scenarioList" @change="onChange">
  41. <el-checkbox v-for="item in commonData.ENTERPRISE_APPLICATION_SCENARIO" :key="item.value"
  42. :label="parseInt(item.value)">{{ item.label }}</el-checkbox>
  43. </el-checkbox-group>
  44. </el-form-item>
  45. <el-form-item label="调查类型" prop="typeList" v-if="show == true">
  46. <el-checkbox-group v-model="ruleForm.typeList">
  47. <template v-for="(item, index) in dictAssociateData">
  48. <el-checkbox :label="parseInt(item.dictChildValue)">
  49. {{ item.dictChildLabel }}
  50. </el-checkbox>
  51. <div v-if="index === dictAssociateData.length - 1" class="more-data-box">
  52. <el-link v-if="moreData" type="primary" icon="el-icon-arrow-down" @click="handleMoreData(0)">更多
  53. </el-link>
  54. <el-link v-else type="primary" icon="el-icon-arrow-up" @click="handleMoreData(1)">收起</el-link>
  55. </div>
  56. </template>
  57. <div v-show="isShow">
  58. <el-checkbox v-for="item in dictSecondAssociateData" :label="parseInt(item.dictChildValue)">
  59. {{ item.dictChildLabel }}
  60. </el-checkbox>
  61. </div>
  62. </el-checkbox-group>
  63. </el-form-item>
  64. <el-form-item label="产品类别/产品" prop="productId" v-if="$permission('/workspace/product')">
  65. <div>
  66. <mySelectButton size='large' style="width:100%">
  67. <div slot="select" style="width:100%">
  68. <mySelectTree style="width:100%" v-model="ruleForm.departmentId" :options="departmentList">
  69. </mySelectTree>
  70. </div>
  71. </mySelectButton>
  72. </div>
  73. </el-form-item>
  74. <el-row :gutter="24">
  75. <el-col :span="12">
  76. <el-form-item label="合同号" prop="contractNo">
  77. <el-input v-model="ruleForm.contractNo" placeholder="请输入合同号"></el-input>
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="12">
  81. <el-form-item label="内部案卷" prop="innerFile">
  82. <el-input v-model="ruleForm.innerFile" placeholder="请输入内部案卷"></el-input>
  83. </el-form-item>
  84. </el-col>
  85. </el-row>
  86. <el-row :gutter="24">
  87. <el-col :span="12">
  88. <el-form-item label="委案日" prop="caseDate">
  89. <el-date-picker v-model="ruleForm.caseDate" value-format="yyyy-MM-dd" type="date" placeholder="请选择委案日"
  90. class="width_100"></el-date-picker>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="12">
  94. <el-form-item label="处理状态" prop="status">
  95. <el-select v-model="ruleForm.status" placeholder="请输入处理状态" class="width_100">
  96. <el-option value="0" label="处理中"></el-option>
  97. <el-option value="1" label="已完成"></el-option>
  98. </el-select>
  99. </el-form-item>
  100. </el-col>
  101. </el-row>
  102. <el-form-item label="备注" prop="remark">
  103. <el-input v-model="ruleForm.remark" placeholder="请输入备注" type="textarea"></el-input>
  104. </el-form-item>
  105. </el-form>
  106. </el-main>
  107. <el-footer class="footer-common"
  108. v-if="($permission('/workspace/project/modify') || $permission('/workspace/project/add')) && ($r(ruleForm.id, [2]) || userinfo.id == ruleForm.createBy)">
  109. <el-button @click="close">取 消</el-button>
  110. <el-button type="primary" @click="submit" :loading="loading">确 定</el-button>
  111. </el-footer>
  112. </el-container>
  113. </el-drawer>
  114. <el-dialog title="选择委托方" :visible.sync="visible" width="800px" append-to-body destroy-on-close :before-close="close2"
  115. top="10vh">
  116. <ClientTable :choseClient="true" @getClient="getClient"></ClientTable>
  117. </el-dialog>
  118. </div>
  119. </template>
  120. <script>
  121. import ClientTable from '@/views/client'
  122. import { mapGetters } from 'vuex';
  123. export default {
  124. components: {
  125. ClientTable
  126. },
  127. props: {
  128. commonData: Object
  129. },
  130. data() {
  131. return {
  132. //抽屉标题
  133. title: '',
  134. //抽屉开关标识
  135. drawer: false,
  136. //表单数据
  137. ruleForm: {},
  138. //表单规则
  139. rules: {},
  140. //控制选择委托方弹窗
  141. visible: false,
  142. //部门列表
  143. departmentList: [],
  144. //人员列表
  145. personnelList: [],
  146. //负责人下拉加载
  147. loading: false,
  148. //显示调查类型
  149. show: false,
  150. //显示更多调查类型
  151. isShow: false,
  152. //显示更多和收起按钮
  153. moreData: true,
  154. //调查类型列表
  155. dictAssociateData: [],
  156. //其他调查类型
  157. dictSecondAssociateData: [],
  158. //用来获取调查类型
  159. test: {
  160. value: '1',
  161. type: 'ENTERPRISE_APPLICATION_SCENARIO',
  162. flag: 1
  163. },
  164. };
  165. },
  166. watch: {},
  167. computed: {
  168. ...mapGetters(['userinfo'])
  169. },
  170. created() { },
  171. mounted() {
  172. },
  173. methods: {
  174. //打开弹窗
  175. open(form, title) {
  176. //获取部门列表
  177. this.getDepartment()
  178. //获取人员列表
  179. this.getPersonnelList()
  180. this.ruleForm = form
  181. this.title = title
  182. this.drawer = true
  183. },
  184. //获取部门列表
  185. getDepartment() {
  186. this.$api.getPermissionDepartmentList().then((response) => {
  187. this.departmentList = response.data;
  188. });
  189. },
  190. //获取人员列表
  191. getPersonnelList() {
  192. this.$api.getPermissionPersonnelList().then((response) => {
  193. this.personnelList = response.data
  194. })
  195. },
  196. //关闭抽屉
  197. close() {
  198. this.drawer = false
  199. },
  200. //远程搜索(建议调取接口获取)
  201. querySearch(queryString, cb) {
  202. // var clientList = this.clientList;
  203. // var results = (queryString ? clientList.filter(this.createFilter(queryString)) : clientList).map(item=>{
  204. // return {
  205. // value:item.name,
  206. // name:item.name,
  207. // id:item.id
  208. // }
  209. // });
  210. // // 调用 callback 返回建议列表的数据
  211. // cb(results);
  212. },
  213. createFilter(queryString) {
  214. return (clientList) => {
  215. return (clientList.name && clientList.name.toLowerCase().indexOf(queryString.toLowerCase()) != -1);
  216. };
  217. },
  218. //输入框输入事件(委托方)
  219. input() {
  220. this.$set(this.ruleForm, 'clientId', -1)
  221. },
  222. //切换选择委托方
  223. handleChange(row) {
  224. this.$set(this.ruleForm, 'clientId', row.id)
  225. this.$set(this.ruleForm, 'clientName', row.name)
  226. this.close2()
  227. },
  228. //打开选择委托方弹窗
  229. handleSelect() {
  230. this.visible = true
  231. },
  232. //获取委托方信息
  233. getClient(row) {
  234. this.$set(this.ruleForm, 'clientId', row.id)
  235. this.$set(this.ruleForm, 'clientName', row.name)
  236. this.close2()
  237. },
  238. //关闭委托方弹窗
  239. close2() {
  240. this.visible = false
  241. },
  242. //负责人远程搜索
  243. remoteMethod(query) {
  244. },
  245. //负责人下拉懒加载
  246. lazyLoading() {
  247. },
  248. //调查类型选择切换
  249. onChange() {
  250. if (this.ruleForm.scenarioList.length != 0) {
  251. this.show = true
  252. this.test.value = this.ruleForm.scenarioList.toString()
  253. this.test.flag = 1
  254. this.$api.getDictTreeByParentDictValue(this.test).then(response => {
  255. this.dictAssociateData = response.data
  256. this.test.value = this.ruleForm.scenarioList.toString()
  257. this.test.flag = 0
  258. this.$api.getDictTreeByParentDictValue(this.test).then(response => {
  259. this.dictSecondAssociateData = response.data
  260. })
  261. })
  262. } else {
  263. this.show = false
  264. }
  265. },
  266. //调查类型展开收起
  267. handleMoreData(type) {
  268. if (type === 0) {
  269. this.isShow = true
  270. this.test.value = this.ruleForm.scenarioList.toString()
  271. this.test.flag = 0
  272. this.$api.getDictTreeByParentDictValue(this.test).then(response => {
  273. this.dictSecondAssociateData = response.data
  274. })
  275. } else if (type === 1) {
  276. this.isShow = false
  277. }
  278. this.moreData = !this.moreData
  279. },
  280. //提交数据
  281. submit() {
  282. this.$refs.ruleForm.validate((valid) => {
  283. if (valid) {
  284. this.show = false
  285. this.loading = true
  286. if (this.ruleForm.id) {
  287. this.$api.editProject(this.ruleForm).then(response => {
  288. this.loading = false
  289. this.$message.success('编辑成功')
  290. this.$emit('submit', 0)
  291. this.close()
  292. }).catch(error => {
  293. this.loading = false
  294. })
  295. } else {
  296. this.$api.addProject(this.ruleForm).then(response => {
  297. this.loading = false
  298. let permissions = this.permissions
  299. permissions[response.data] = 0
  300. this.$store.commit('SET_PERMISSIONS', permissions)
  301. this.$message.success('新增成功')
  302. this.$emit('submit', 1)
  303. this.close()
  304. }).catch(error => {
  305. this.show = true
  306. this.loading = false
  307. })
  308. }
  309. }
  310. })
  311. },
  312. },
  313. };
  314. </script>
  315. <style lang="scss" scoped></style>