华西海圻ELN前端工程
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

352 lines
12 KiB

  1. <template>
  2. <div>
  3. <div class="edit-container" v-if="open">
  4. <div class="edit-top">
  5. <div class="left-top">
  6. <img src="@/assets/images/back.png" @click="cancel()" />
  7. <div class="left-title"></div>
  8. </div>
  9. <div class="center-top">
  10. <div>
  11. <div :class="showIndex == 1 ? 'el-step__icon is-text is-finish' : 'el-step__icon is-text is-info'">
  12. <div class="el-step__icon-inner">1</div>
  13. </div>
  14. {{ $t('page.business.study.studyFormPlan.jcsz') }}
  15. </div>
  16. <div class="line"></div>
  17. <div>
  18. <div :class="showIndex == 2 ? 'el-step__icon is-text is-finish' : 'el-step__icon is-text is-info'">
  19. <div class="el-step__icon-inner">2</div>
  20. </div>
  21. {{ $t('page.business.study.studyFormPlan.bdtb') }}
  22. </div>
  23. </div>
  24. <div class="right-top">
  25. <el-button @click="cancel()">{{ $t('form.cancel') }}</el-button>
  26. <template v-if="showIndex == 1">
  27. <el-button @click="save">{{ $t('page.business.study.studyFormPlan.zc') }}</el-button>
  28. <el-button type="primary" @click="next">{{ $t('page.business.study.studyFormPlan.next') }}</el-button>
  29. </template>
  30. <template v-else>
  31. <el-button @click="saveNext">{{ $t('page.business.study.studyFormPlan.save') }}</el-button>
  32. <el-button type="primary" @click="showtijiao">{{ $t('page.business.study.studyFormPlan.submit')
  33. }}</el-button>
  34. <el-button type="primary" @click="pre">{{ $t('page.business.study.studyFormPlan.pre') }}</el-button>
  35. </template>
  36. </div>
  37. </div>
  38. <div class="edit-content">
  39. <div class="content" style="width:60%" v-show="showIndex == 1">
  40. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  41. <el-row>
  42. <el-col :span="24">
  43. <el-form-item :label="$t('page.business.form.bdmb')" prop="templateId">
  44. <SelectTemplate v-model="form.templateId" :studyType="studyType" :studyFormType="studyFormType"
  45. :needPre="1" :name="form.templateMc" @change="selectTemplateChange" />
  46. </el-form-item>
  47. </el-col>
  48. </el-row>
  49. <el-row>
  50. <el-col :span="24">
  51. <el-form-item :label="$t('page.business.form.bdmc')" prop="bdmc">
  52. <el-input type="text" v-model="form.bdmc" maxlength="50" :placeholder="$t('form.placeholderInput')" />
  53. </el-form-item>
  54. </el-col>
  55. </el-row>
  56. <el-row>
  57. <el-col :span="24">
  58. <el-form-item :label="$t('page.business.study.studyFormPlan.bdsm')" prop="bdsm">
  59. <el-input type="textarea" v-model="form.bdsm" :rows="5" maxlength="500"
  60. :placeholder="$t('form.placeholderInput')">
  61. </el-input>
  62. </el-form-item>
  63. </el-col>
  64. </el-row>
  65. </el-form>
  66. </div>
  67. <div class="content" v-if="showIndex == 2&&templateData.templateId">
  68. <TemplateTable ref="templateTable" emitName="onPlanCallback" @onPlanCallback="onPlanCallback"
  69. :sn="form.templateSn" :templateData="templateData" fillType="actFill" />
  70. </div>
  71. </div>
  72. </div>
  73. <el-dialog :title="$t('page.business.study.studyFormPlan.tjjl')" :visible.sync="openSubmit" width="500px"
  74. append-to-body :close-on-click-modal="false">
  75. <el-form ref="formSubmit" :model="form" :rules="rulesApprove" label-width="120px" v-if="openSubmit">
  76. <div class="sbzdtcma"> <input type="text"> <input type="password" show-password> </div>
  77. <el-row>
  78. <el-col :span="24">
  79. <el-form-item :label="$t('page.business.study.studyFormPlan.shryId')" prop="fshryId">
  80. <SelectStudyUser v-model="form.fshryId" :query="{
  81. studyId: form.studyId,
  82. permit: 'business:studyFormPlan:fh'
  83. }" key="fshryId" @change="selectDeptUserChange" />
  84. </el-form-item>
  85. </el-col>
  86. </el-row>
  87. <el-row>
  88. <el-col :span="24">
  89. <el-form-item :label="$t('form.qmyy')" prop="qmyy">
  90. <el-input type="text" :value="form.qmyy" maxlength="50" disabled
  91. :placeholder="$t('form.placeholderInput')" />
  92. </el-form-item>
  93. </el-col>
  94. </el-row>
  95. <el-row>
  96. <el-col :span="24">
  97. <el-form-item :label="$t('form.remark')" prop="remark">
  98. <el-input type="textarea" v-model="form.remark" :rows="5" maxlength="500"
  99. :placeholder="$t('form.placeholderInput')">
  100. </el-input>
  101. </el-form-item>
  102. </el-col>
  103. </el-row>
  104. <el-row>
  105. <el-col :span="24">
  106. <el-form-item :label="$t('form.signer')">
  107. <el-input type="text" v-model="nickName" maxlength="50" disabled
  108. :placeholder="$t('form.placeholderInput')" />
  109. </el-form-item>
  110. </el-col>
  111. </el-row>
  112. <el-row>
  113. <el-col :span="24">
  114. <el-form-item :label="$t('form.password')" prop="qmrmm">
  115. <div class="sbzdtcma"> <input type="text"></div>
  116. <el-input type="password" @contextmenu.native.prevent @copy.native.prevent @cut.native.prevent show-password v-model="form.qmrmm" maxlength="20"
  117. :placeholder="$t('form.placeholderInput')" />
  118. </el-form-item>
  119. </el-col>
  120. </el-row>
  121. </el-form>
  122. <div slot="footer" class="dialog-footer">
  123. <el-button type="primary" @click="tj">{{ $t('form.confirm') }}</el-button>
  124. <el-button @click="openSubmit = false">{{ $t('form.cancel') }}</el-button>
  125. </div>
  126. </el-dialog>
  127. </div>
  128. </template>
  129. <script>
  130. import { studyFormPlan_bc, studyFormPlan_bcOnly, studyFormPlan_tj, studyFormPlan_info, studyFormPlan_updateBdnr, studyFormFill_updateFhyjjl } from "@/api/business/study/studyFormPlan"
  131. import { mapGetters } from 'vuex'
  132. import SelectTemplate from "@/views/business/comps/select/SelectTemplate";
  133. import SelectStudyUser from '@/views/business/comps/select/SelectStudyUser';
  134. import TemplateTable from '@/views/business/comps/template/TemplateTable';
  135. import { deepClone } from "@/utils/index";
  136. export default {
  137. name: "Bj",
  138. components: { SelectTemplate, SelectStudyUser, TemplateTable },
  139. data() {
  140. return {
  141. open: false,
  142. showIndex: 1,
  143. form: {},
  144. openSubmit: false,
  145. rulesApprove: {
  146. // fshryId: [{
  147. // required: true,
  148. // message: ' ',
  149. // trigger: 'blur'
  150. // }],
  151. qmrmm: [{
  152. required: true,
  153. message: ' ',
  154. trigger: 'blur'
  155. }],
  156. fzrsh: [{
  157. required: true,
  158. message: ' ',
  159. trigger: 'blur'
  160. }],
  161. shryId: [{
  162. required: true,
  163. message: ' ',
  164. trigger: 'blur'
  165. }]
  166. },
  167. rules: {
  168. bdmc: [{
  169. required: true,
  170. message: ' ',
  171. trigger: 'blur'
  172. }],
  173. templateId: [{
  174. required: true,
  175. message: ' ',
  176. trigger: 'blur'
  177. }],
  178. },
  179. templateData: {},
  180. studyType: null,
  181. studyFormType: null
  182. }
  183. },
  184. computed: {
  185. ...mapGetters([
  186. 'nickName', 'name'
  187. ]),
  188. },
  189. created() {
  190. },
  191. methods: {
  192. onPlanCallback(data) {
  193. console.log("data:" + JSON.stringify(data))
  194. console.log("formdata:" + JSON.stringify(this.$refs.templateTable.getFilledFormData()))
  195. if (data.type == 'fieldChanged') {
  196. studyFormPlan_updateBdnr(
  197. {
  198. id: this.form.id,
  199. bdnr: JSON.stringify(this.$refs.templateTable.getFilledFormData()),
  200. zdxgjl: JSON.stringify(data.resourceList),
  201. filedValue: JSON.stringify(data.newRecord),
  202. submittedCodes: data.submittedCodes ? JSON.stringify(data.submittedCodes) : ''
  203. }
  204. ).then(response => {
  205. })
  206. } else if (data.type == 'reply') {
  207. studyFormFill_updateFhyjjl(
  208. {
  209. id: this.form.id,
  210. reply: JSON.stringify(data.newRecord),
  211. fhyjjl: JSON.stringify(data.resourceList)
  212. }
  213. ).then(response => {
  214. })
  215. }
  216. },
  217. pre() {
  218. this.showIndex = 1
  219. },
  220. next() {
  221. this.$refs["form"].validate(valid => {
  222. if (valid) {
  223. this.$modal.loading()
  224. studyFormPlan_bcOnly(this.form).then(response => {
  225. this.form = response.data
  226. this.templateData.bdmc = this.form.bdmc
  227. this.showIndex = 2
  228. this.$modal.closeLoading()
  229. }).finally(() => {
  230. this.$modal.closeLoading()
  231. })
  232. }
  233. })
  234. },
  235. selectTemplateChange(val) {
  236. if (this.$i18n.locale === 'zh_CN') {
  237. this.form.templateMc = val.name
  238. this.form.bdmc = val.name
  239. } else {
  240. this.form.templateMc = val.nameEn
  241. this.form.bdmc = val.nameEn
  242. }
  243. this.form.bdnr = val.content
  244. this.form.templateSn = val.sn
  245. this.templateData = deepClone(this.form)
  246. setTimeout(() => {
  247. this.$refs["form"].validate()
  248. }, 200)
  249. },
  250. cancel() {
  251. this.$emit('close')
  252. this.open = false
  253. },
  254. reset() {
  255. this.form = {
  256. id: null,
  257. studyId: null,
  258. bdbh: null,
  259. bdmc: this.$i18n.locale === 'zh_CN'?'试验物质配制计划表':'试验物质配制计划表',
  260. bdsm: null,
  261. qmyy:this.$t('page.business.study.studyFormFill.txbtjjl'),
  262. templateId: 1,
  263. templateMc: this.$i18n.locale === 'zh_CN'?'试验物质配制计划表':'试验物质配制计划表',
  264. templateSn: 'SYWZPZJHB',
  265. bdnr: null,
  266. fzrsh: null,
  267. shryId: null,
  268. shryMc: null,
  269. }
  270. this.resetForm("form")
  271. },
  272. selectDeptUserChange(val) {
  273. this.form.fhryMc = val.name
  274. },
  275. edit(row) {
  276. this.reset()
  277. this.studyType = row.studyType || null
  278. this.studyFormType = row.studyFormType || 10
  279. if (row && row.id) {
  280. this.showIndex = 2
  281. this.$modal.loading()
  282. studyFormPlan_info({ id: row.id }).then(response => {
  283. this.form = response.data
  284. this.templateData = deepClone(this.form)
  285. this.saveSimpleLog({ jcmc: '计划表单编辑', jcmcEn: 'Plan Table Edit', name: this.form.bdmc + '(' + this.form.bdbh + ')', nameEn: this.form.bdmc + '(' + this.form.bdbh + ')' })
  286. this.open = true
  287. this.form.qmyy = this.$t('page.business.study.studyFormFill.txbtjjl')
  288. }).finally(() => {
  289. this.$modal.closeLoading()
  290. })
  291. } else {
  292. this.showIndex = 1
  293. this.form = _.merge({}, this.form, row)
  294. this.templateData = deepClone(this.form)
  295. let name = this.studyType == 1 ? '试验' : (this.studyType == 5 ? '非试验表单' : '麻精药表单')
  296. let nameEn = this.studyType == 1 ? 'Study' : (this.studyType == 5 ? 'Non-study' : 'ontrolled Drug')
  297. this.saveSimpleLog({ jcmc: '计划表单新增', jcmcEn: 'Plan Table Create', name: name, nameEn: nameEn })
  298. this.form.qmyy = this.$t('page.business.study.studyFormFill.txbtjjl')
  299. this.open = true
  300. }
  301. },
  302. save() {
  303. this.$refs["form"].validate(valid => {
  304. if (valid) {
  305. this.$modal.loading()
  306. studyFormPlan_bc(this.form).then(response => {
  307. this.$emit('close')
  308. this.open = false
  309. }).finally(() => {
  310. this.$modal.closeLoading()
  311. })
  312. }
  313. })
  314. },
  315. async saveNext() {
  316. this.form.bdnr = JSON.stringify(this.$refs.templateTable.getFilledFormData())
  317. this.$modal.loading()
  318. studyFormPlan_bc(this.form).then(response => {
  319. this.$emit('close')
  320. this.open = false
  321. }).finally(() => {
  322. this.$modal.closeLoading()
  323. })
  324. },
  325. tj() {
  326. this.$refs["formSubmit"].validate(valid => {
  327. if (valid) {
  328. this.$modal.loading()
  329. studyFormPlan_tj(this.form).then(response => {
  330. this.$emit('close')
  331. this.open = false
  332. this.openSubmit = false
  333. }).finally(() => {
  334. this.$modal.closeLoading()
  335. })
  336. }
  337. })
  338. },
  339. async showtijiao() {
  340. let content = await this.$refs.templateTable.getFormData()
  341. if (content) {
  342. this.form.bdnr = JSON.stringify(content)
  343. this.openSubmit = true
  344. }
  345. }
  346. }
  347. }
  348. </script>