华西海圻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.

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