operationGuideDialog.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <!-- 操作手册弹窗 -->
  2. <template>
  3. <el-dialog
  4. class="ele-dialog-form"
  5. title="编辑"
  6. v-if="visible"
  7. :append-to-body="true"
  8. :visible.sync="visible"
  9. :before-close="handleClose"
  10. :close-on-click-modal="false"
  11. :close-on-press-escape="false"
  12. width="1000px"
  13. >
  14. <headerTitle title="操作工具">
  15. <el-button type="primary" size="small" @click="handleAdd">新增</el-button>
  16. </headerTitle>
  17. <el-table
  18. ref="multipleTable"
  19. :data="form.toolList"
  20. tooltip-effect="dark"
  21. style="width: 100%"
  22. stripe
  23. :header-cell-style="{ background: '#EEEEEE', border: 'none' }"
  24. >
  25. <el-table-column label="工具名称" prop="code" min-width="120">
  26. <template slot-scope="{ row }">
  27. {{ row.name }}
  28. </template></el-table-column
  29. >
  30. <el-table-column label="工具编码" prop="code" min-width="120">
  31. <template slot-scope="{ row }">
  32. {{ row.code }}
  33. </template></el-table-column
  34. >
  35. <el-table-column label="牌号" prop="brandNum" min-width="120">
  36. <template slot-scope="{ row }">
  37. {{ row.brandNum }}
  38. </template></el-table-column
  39. >
  40. <el-table-column label="型号" prop="modelType" min-width="120">
  41. <template slot-scope="{ row }">
  42. {{ row.modelType }}
  43. </template></el-table-column
  44. >
  45. <el-table-column label="操作" fixed="right">
  46. <template slot-scope="{ $index, row }">
  47. <el-button type="text" @click="removeItem($index, row)"
  48. >删除设备</el-button
  49. >
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. <headerTitle title="操作指导">
  54. <el-button type="primary" size="small" @click="addPostscript"
  55. >新增</el-button
  56. >
  57. </headerTitle>
  58. <el-table
  59. ref="multipleTable"
  60. :data="form.procedureList"
  61. tooltip-effect="dark"
  62. style="width: 100%"
  63. stripe
  64. :header-cell-style="{ background: '#EEEEEE', border: 'none' }"
  65. >
  66. <el-table-column type="index" width="50"> </el-table-column>
  67. <!-- <el-table-column label="排序" prop="" width="100">
  68. <template slot-scope="{ row }">
  69. <el-input
  70. placeholder="请输入"
  71. type="number"
  72. v-model.number="row.sort"
  73. clearable
  74. ></el-input> </template
  75. ></el-table-column> -->
  76. <el-table-column label="操作步骤" prop="" min-width="120">
  77. <template slot-scope="{ row }">
  78. <el-input
  79. placeholder="请输入"
  80. type="textarea"
  81. :rows="1"
  82. v-model="row.content"
  83. clearable
  84. ></el-input> </template
  85. ></el-table-column>
  86. <el-table-column label="操作" fixed="right" width="100">
  87. <template slot-scope="{ $index, row }">
  88. <el-button type="text" @click="removePostscript($index, row)"
  89. >删除</el-button
  90. >
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <template v-slot:footer>
  95. <el-button @click="handleClose">取消</el-button>
  96. <el-button type="primary" :loading="loading" @click="save">
  97. 保存
  98. </el-button>
  99. </template>
  100. <ProductModal ref="productRefs" @chooseModal="chooseModal" />
  101. </el-dialog>
  102. </template>
  103. <script>
  104. // import { update, getById } from '@/api/inspectionClassify';
  105. import ProductModal from './ProductModal.vue';
  106. export default {
  107. components: {
  108. ProductModal
  109. },
  110. data() {
  111. const defaultForm = function () {
  112. return {
  113. toolList: [],
  114. procedureList: []
  115. };
  116. };
  117. return {
  118. defaultForm,
  119. // 表单数据
  120. form: { ...defaultForm() },
  121. currentIndex: 0,
  122. // 表单验证规则
  123. rules: {
  124. name: [{ required: true, message: '请输入', trigger: 'blur' }],
  125. type: {
  126. required: true,
  127. message: '请选择',
  128. trigger: 'change'
  129. }
  130. },
  131. visible: false,
  132. title: null,
  133. loading: false
  134. };
  135. },
  136. created() {},
  137. methods: {
  138. open(row, index) {
  139. console.log(row);
  140. console.log(index);
  141. if (row) {
  142. this.form = row;
  143. }
  144. this.currentIndex = index;
  145. this.visible = true;
  146. },
  147. /* 保存编辑 */
  148. save() {
  149. this.$emit('save', this.form, this.currentIndex);
  150. this.visible = false;
  151. },
  152. restForm() {
  153. this.form = { ...this.defaultForm() };
  154. },
  155. handleClose() {
  156. this.restForm();
  157. this.visible = false;
  158. },
  159. handleAdd() {
  160. this.$refs.productRefs.open(this.form.toolList);
  161. },
  162. chooseModal(data) {
  163. this.form.toolList = [...this.form.toolList, ...data];
  164. },
  165. removeItem(idx, row) {
  166. if (this.form.toolList.length == 1) {
  167. return this.$message.error('至少保留一个设备!');
  168. }
  169. this.$confirm(`是否删除这个设备?`).then(async () => {
  170. this.form.toolList.splice(idx, 1);
  171. if (row.id) {
  172. this.form.toolRemoveIds.push(row.id);
  173. }
  174. });
  175. },
  176. addPostscript() {
  177. this.form.procedureList.push({ sort: null, content: '' });
  178. },
  179. removePostscript(idx, row) {
  180. if (this.form.procedureList.length == 1) {
  181. return this.$message.error('至少保留一个事项!');
  182. }
  183. this.$confirm(`是否删除这个事项?`).then(async () => {
  184. this.form.procedureList.splice(idx, 1);
  185. });
  186. }
  187. }
  188. };
  189. </script>
  190. <style lang="scss" scoped>
  191. .location-warp {
  192. display: flex;
  193. .detail {
  194. margin-left: 10px;
  195. }
  196. }
  197. :deep(
  198. .el-dialog:not(.ele-dialog-form)
  199. .el-dialog__body
  200. .el-form
  201. .el-form-item:last-child
  202. ) {
  203. margin-bottom: 22px;
  204. }
  205. </style>