add.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. {extend name="common/common2" /}
  2. {block name="main"}
  3. <div class="row">
  4. <div class="col-sm-12">
  5. <div class="ibox float-e-margins">
  6. <div class="ibox-content" id="vuequality">
  7. <form method="post" action="{:url('add')}" class="form-horizontal">
  8. <input type="hidden" name="id" value="{$info['id']|default='0'}">
  9. <div class="form-group">
  10. <label class="col-sm-2 control-label">名称<span class="text-danger">*</span></label>
  11. <div class="col-sm-6">
  12. <input type="text" class="form-control" name="title" value="{$info.title|default=''}">
  13. </div>
  14. </div>
  15. <div class="form-group">
  16. <label class="col-sm-2 control-label">检查项<span class="text-danger">*</span></label>
  17. <div class="col-sm-6">
  18. <!-- {:widget_view('common/multiselect',['name'=>'forms','lists' => $patrol_form, 'val' => isset($info)?$info['forms']:[]])}-->
  19. <input type="hidden" id="ele-forms" name="forms">
  20. <el-select
  21. v-model="forms"
  22. multiple
  23. collapse-tags
  24. filterable
  25. size="small"
  26. style="width:100%"
  27. placeholder="请选择"
  28. @change="selectForms"
  29. >
  30. <el-option
  31. v-for="item in pforms"
  32. :key="item.id"
  33. :label="item.title"
  34. :value="item.id.toString()">
  35. </el-option>
  36. </el-select>
  37. </div>
  38. </div>
  39. <div class="form-group">
  40. <label class="col-sm-2 control-label">关联业务</label>
  41. <div class="col-sm-6">
  42. <input type="hidden" id="ele-type" name="type">
  43. <select v-model="type" class="form-control" @change="changeType">
  44. <option :value="0">不关联业务</option>
  45. <option :value="1">巡更</option>
  46. <option :value="2">巡视</option>
  47. <option :value="3">巡查</option>
  48. <option :value="4">巡检</option>
  49. <option :value="5">日常工作</option>
  50. <option :value="6">设备台账</option>
  51. </select>
  52. </div>
  53. </div>
  54. <div class="form-group">
  55. <label class="col-sm-2 control-label">关联项</label>
  56. <div class="col-sm-6">
  57. <input type="hidden" id="ele-busids" name="busids">
  58. <el-select
  59. v-model="busids"
  60. multiple
  61. collapse-tags
  62. filterable
  63. size="small"
  64. style="width:100%"
  65. placeholder="请选择"
  66. >
  67. <el-option
  68. v-for="item in blists"
  69. :key="item.id"
  70. :label="item.title"
  71. :value="item.id.toString()">
  72. </el-option>
  73. </el-select>
  74. </div>
  75. </div>
  76. <div class="form-group">
  77. <label class="col-sm-2 control-label">备注</label>
  78. <div class="col-sm-6">
  79. <textarea name="remark" class="form-control" rows="3">{$info.remark|default=''}</textarea>
  80. </div>
  81. </div>
  82. <div class="form-group">
  83. <label class="col-sm-2 control-label">状态</label>
  84. <div class="col-sm-6">
  85. <label class="cr-inline">
  86. <input type="radio" value="1" name="enable">正常&nbsp;&nbsp;
  87. </label>
  88. <label class="cr-inline">
  89. <input type="radio" value="0" name="enable">禁用
  90. </label>
  91. </div>
  92. </div>
  93. <div class="hr-line-dashed"></div>
  94. <div class="form-group">
  95. <div class="col-sm-6 col-sm-offset-2">
  96. <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
  97. <button class="btn cancel-btn btn-default" type="button">取 消</button>
  98. </div>
  99. </div>
  100. </form>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. {/block}
  106. {block name="script"}
  107. <script>
  108. var glarr = {:json_encode($glarr)};
  109. var pform = {:json_encode($patrol_form)};
  110. {notempty name="info"}
  111. var info = {:json_encode($info)};
  112. {else /}
  113. var info = null;
  114. {/notempty}
  115. $(document).ready(function(){
  116. formSetValue("enable", {$info.enable|default=1});
  117. // formSetValue("type", {$info.type|default=0});
  118. });
  119. new Vue({
  120. el: '#vuequality',
  121. data: function () {
  122. return {
  123. info: info,
  124. initarr: glarr,
  125. type: 0,
  126. forms: [],
  127. busids: [],
  128. pforms: pform,
  129. blists:[]
  130. }
  131. },
  132. watch: {
  133. forms: function (newVal, oldVal) {
  134. $('#ele-forms').val(newVal.join(','));
  135. },
  136. busids: function (newVal, oldVal) {
  137. $('#ele-busids').val(newVal.join(','));
  138. },
  139. type: function (newVal, oldVal) {
  140. $('#ele-type').val(newVal);
  141. }
  142. },
  143. created: function () {
  144. if(this.info){
  145. this.type = this.info.type;
  146. this.changeType();
  147. this.forms = this.info.forms?this.info.forms.split(','):[];
  148. this.busids = this.info.busids?this.info.busids.split(','):[];
  149. }
  150. },
  151. methods: {
  152. selectForms(){
  153. console.log('forms',this.forms);
  154. },
  155. changeType(){
  156. this.blists = [];
  157. this.busids = [];
  158. let arr = [];
  159. this.initarr.forEach((item) => {
  160. if((item.id) == Number(this.type)){
  161. arr = item.lists;
  162. }
  163. });
  164. console.log(this.initarr,arr,this.type);
  165. this.$nextTick(() => {
  166. this.blists = JSON.parse(JSON.stringify(arr));
  167. })
  168. },
  169. }
  170. });
  171. </script>
  172. {/block}