Process.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <div>
  3. <FullPage title='工序分类字段'
  4. :list='list'
  5. :loading='loading'
  6. @init='init'
  7. @searchData='init'
  8. @changePage='changePage'
  9. @changeSize='changeSize'
  10. :tableColums='tableColums'
  11. :tableData='tableData'
  12. :pageIndex='pageIndex'
  13. :total='total'>
  14. <div slot='titleButton'>
  15. <Button type="primary"
  16. ghost
  17. icon='md-add'
  18. @click="addItems(null,1,null)">新增工序分类</Button>
  19. </div>
  20. <div slot='navButton'>
  21. </div>
  22. <template slot='set'
  23. slot-scope='{row}'>
  24. <div class="table-set">
  25. <svg @click="addItems(row,1,null)"
  26. class="icon icon-nav"
  27. aria-hidden="true">
  28. <use xlink:href="#iconxinzengshuxing"></use>
  29. </svg>
  30. <svg style="font-size:20px"
  31. color='#3764FF'
  32. @click="addItems(row,2,1)"
  33. class="icon icon-nav"
  34. aria-hidden="true">
  35. <use xlink:href="#iconbianji"></use>
  36. </svg>
  37. <svg @click="delItems(row)"
  38. class="icon icon-nav"
  39. style="font-size:20px"
  40. color='red'
  41. aria-hidden="true">
  42. <use xlink:href="#iconshanchu"></use>
  43. </svg>
  44. </div>
  45. </template>
  46. <div>
  47. <Modal class-name="vertical-center-modal"
  48. @on-ok="postInfo"
  49. :title="showType == 1 ? '添加子集': '编辑子集'"
  50. v-model="showModal"
  51. :width="480"
  52. @on-visible-change='vivibleModal'>
  53. <Form :label-width="90">
  54. <FormItem label="ID:">
  55. <Input disabled
  56. placeholder="ID自动生成"
  57. v-model="classInfo.id" />
  58. </FormItem>
  59. <FormItem label="分类名称:">
  60. <Input placeholder="请输入分类名称"
  61. v-model="classInfo.title" />
  62. </FormItem>
  63. <FormItem label='类型:'>
  64. <Select v-model="classInfo.type">
  65. <Option :value='1'>生产</Option>
  66. <Option :value='2'>运输</Option>
  67. <Option :value='3'>安装</Option>
  68. <Option :value='4'>包装</Option>
  69. </Select>
  70. </FormItem>
  71. </Form>
  72. </Modal>
  73. </div>
  74. </FullPage>
  75. </div>
  76. </template>
  77. <script>
  78. import Tables from '../../components/table-column/index'
  79. export default {
  80. data () {
  81. const vm = this
  82. return {
  83. list: [
  84. { title: '工序分类名称', name: 'Input', value: '', serverName: 'title', placeholder: '请输入工序分类名称' },
  85. ],
  86. tableColums: [
  87. {
  88. type: 'expand', title: '展开', width: '70', slot: 'open',
  89. render (h, params) {
  90. const { row } = params
  91. return h(Tables, {
  92. props: {
  93. tableDatas: params.row.child || []
  94. },
  95. on: {
  96. updataTables: (array) => vm._data.tableData = array
  97. }
  98. })
  99. }
  100. },
  101. { title: '序号', type: 'index', align: 'center', key: 'id', width: '100' },
  102. { title: '工序分类名称', align: 'center', key: 'title' },
  103. { title: '操作', align: 'center', slot: 'set', width: '150' },
  104. ],
  105. tableData: [],
  106. pageIndex: 1,
  107. total: 0,
  108. pageSize: 10,
  109. showType: 1,
  110. showModal: false,
  111. classInfo: {},
  112. proxyObj: {},
  113. loading: false,
  114. }
  115. },
  116. methods: {
  117. init (row) {
  118. this.pageIndex = 1
  119. row.page_size = this.pageSize;
  120. row.page_index = this.pageIndex;
  121. this.proxyObj = row;
  122. this.getData(row)
  123. },
  124. getData (row) {
  125. this.loading = true;
  126. this.axios('/api/basics_procedure_index', { params: row }).then(res => {
  127. this.loading = false;
  128. this.tableData = res.data.data;
  129. this.total = res.data.total;
  130. })
  131. },
  132. changePage (e) {
  133. this.pageIndex = e;
  134. this.proxyObj.page_index = this.pageIndex;
  135. this.getData(this.proxyObj)
  136. },
  137. changeSize (e) {
  138. this.pageSize = e;
  139. this.proxyObj.page_size = this.pageSize
  140. this.getData(this.proxyObj)
  141. },
  142. postInfo () {
  143. let post_url = this.showType == 1 ? '/api/basics_procedure_add' : '/api/basics_procedure_edit';
  144. this.axios.post(post_url, this.classInfo).then(res => {
  145. if (res.code == 200) {
  146. this.$Message.success(res.msg)
  147. this.getData(this.searchObj)
  148. }
  149. })
  150. },
  151. vivibleModal (e) {
  152. if (!e) {
  153. this.classInfo = {
  154. id: null,
  155. title: '',
  156. type: 1,
  157. }
  158. }
  159. },
  160. addItems (obj, type, edit) {
  161. this.showModal = true;
  162. this.showType = type;
  163. if (obj) {
  164. this.classInfo.id = obj.id;
  165. this.classInfo.title = edit == 1 ? obj.title : '';
  166. this.classInfo.type = obj.type || 1;
  167. } else {
  168. //新增
  169. this.showType = 1
  170. }
  171. },
  172. delItems (row) {
  173. this.confirmDelete({
  174. content: '确认删除么?',
  175. then: () => {
  176. this.axios.post('/api/basics_procedure_del', { id: row.id, state: 0 }).then(res => {
  177. if (res.code == 200) {
  178. this.$Message.success(res.msg)
  179. this.getData(this.proxyObj)
  180. }
  181. })
  182. }
  183. })
  184. },
  185. saveTables (array) {
  186. this.tableData = Array
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. .nav {
  193. display: flex;
  194. justify-content: space-between;
  195. align-items: center;
  196. }
  197. .icon-nav {
  198. margin-right: 5px;
  199. font-size: 16px;
  200. }
  201. /deep/ td.ivu-table-expanded-cell {
  202. padding: 15px 10px;
  203. }
  204. </style>