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

336 lines
11 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" :needPre="1" :name="form.templateMc"
  45. @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">
  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" 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. }
  203. ).then(response => {
  204. })
  205. } else if (data.type == 'reply') {
  206. studyFormFill_updateFhyjjl(
  207. {
  208. id: this.form.id,
  209. reply: JSON.stringify(data.newRecord),
  210. fhyjjl: JSON.stringify(data.resourceList)
  211. }
  212. ).then(response => {
  213. })
  214. }
  215. },
  216. pre() {
  217. this.showIndex = 1
  218. },
  219. next() {
  220. this.$refs["form"].validate(valid => {
  221. if (valid) {
  222. this.$modal.loading()
  223. studyFormPlan_bcOnly(this.form).then(response => {
  224. this.form = response.data
  225. this.templateData.bdmc = this.form.bdmc
  226. this.showIndex = 2
  227. this.$modal.closeLoading()
  228. }).finally(() => {
  229. this.$modal.closeLoading()
  230. })
  231. }
  232. })
  233. },
  234. selectTemplateChange(val) {
  235. this.form.bdnr = val.content
  236. this.form.bdmc = val.name
  237. this.form.templateMc = val.name
  238. this.form.templateSn = val.sn
  239. this.templateData = deepClone(this.form)
  240. },
  241. cancel() {
  242. this.$emit('close')
  243. this.open = false
  244. },
  245. reset() {
  246. this.form = {
  247. id: null,
  248. studyId: null,
  249. bdbh: null,
  250. bdmc: '试验物质配制计划表',
  251. bdsm: null,
  252. templateId: 1,
  253. templateMc: '试验物质配制计划表',
  254. templateSn: 'SYWZPZJHB',
  255. bdnr: null,
  256. fzrsh: null,
  257. shryId: null,
  258. shryMc: null,
  259. }
  260. this.resetForm("form")
  261. },
  262. selectDeptUserChange(val) {
  263. this.form.fhryMc = val.name
  264. },
  265. edit(row) {
  266. this.reset()
  267. this.studyType = row.studyType||null
  268. this.studyFormType = row.studyFormType||null
  269. this.form.qmyy = this.$t('page.business.study.studyFormPlan.cjjl')
  270. if (row && row.id) {
  271. this.showIndex = 2
  272. this.$modal.loading()
  273. studyFormPlan_info({ id: row.id }).then(response => {
  274. this.form = response.data
  275. this.templateData = deepClone(this.form)
  276. this.open = true
  277. }).finally(() => {
  278. this.$modal.closeLoading()
  279. })
  280. } else {
  281. this.showIndex = 1
  282. this.form = _.merge({}, this.form, row)
  283. this.templateData = deepClone(this.form)
  284. this.open = true
  285. }
  286. },
  287. save() {
  288. this.$refs["form"].validate(valid => {
  289. if (valid) {
  290. this.$modal.loading()
  291. studyFormPlan_bc(this.form).then(response => {
  292. this.$emit('close')
  293. this.open = false
  294. }).finally(() => {
  295. this.$modal.closeLoading()
  296. })
  297. }
  298. })
  299. },
  300. async saveNext() {
  301. this.form.bdnr = JSON.stringify(this.$refs.templateTable.getFilledFormData())
  302. this.$modal.loading()
  303. studyFormPlan_bc(this.form).then(response => {
  304. this.$emit('close')
  305. this.open = false
  306. }).finally(() => {
  307. this.$modal.closeLoading()
  308. })
  309. },
  310. tj() {
  311. this.$refs["formSubmit"].validate(valid => {
  312. if (valid) {
  313. this.$modal.loading()
  314. studyFormPlan_tj(this.form).then(response => {
  315. this.$emit('close')
  316. this.open = false
  317. this.openSubmit = false
  318. }).finally(() => {
  319. this.$modal.closeLoading()
  320. })
  321. }
  322. })
  323. },
  324. async showtijiao() {
  325. let content = await this.$refs.templateTable.getFormData()
  326. if (content) {
  327. this.form.bdnr = JSON.stringify(content)
  328. this.openSubmit = true
  329. }
  330. }
  331. }
  332. }
  333. </script>